Fix deprecation warnings
This commit is contained in:
@@ -158,6 +158,7 @@ class Command(BaseCommand):
|
||||
else:
|
||||
# normally this would be easily done with open(mode='x'/'w'),
|
||||
# but python 2 is a pain in the ass as usual
|
||||
# TODO: simplify when dropping support for python 2.7
|
||||
flags = os.O_CREAT | os.O_WRONLY
|
||||
flags = flags | (os.O_TRUNC if overwrite else os.O_EXCL)
|
||||
with os.fdopen(os.open(output_file, flags), "w") as stream:
|
||||
|
||||
@@ -12,6 +12,11 @@ from inflection import camelize
|
||||
|
||||
from .utils import filter_none, force_real_str
|
||||
|
||||
try:
|
||||
from collections import abc as collections_abc
|
||||
except ImportError:
|
||||
collections_abc = collections
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
TYPE_OBJECT = "object" #:
|
||||
@@ -136,7 +141,7 @@ class SwaggerDict(OrderedDict):
|
||||
# handle __proxy__ objects from django.utils.functional.lazy
|
||||
obj = obj._proxy____cast()
|
||||
|
||||
if isinstance(obj, collections.Mapping):
|
||||
if isinstance(obj, collections_abc.Mapping):
|
||||
result = OrderedDict()
|
||||
memo[id(obj)] = result
|
||||
items = obj.items()
|
||||
@@ -147,7 +152,7 @@ class SwaggerDict(OrderedDict):
|
||||
return result
|
||||
elif isinstance(obj, six.string_types):
|
||||
return force_real_str(obj)
|
||||
elif isinstance(obj, collections.Iterable) and not isinstance(obj, collections.Iterator):
|
||||
elif isinstance(obj, collections_abc.Iterable) and not isinstance(obj, collections_abc.Iterator):
|
||||
return type(obj)(SwaggerDict._as_odict(elem, memo) for elem in obj)
|
||||
|
||||
return obj
|
||||
|
||||
@@ -112,7 +112,7 @@ def get_schema_view(info=None, url=None, patterns=None, urlconf=None, public=Fal
|
||||
def as_cached_view(cls, cache_timeout=0, cache_kwargs=None, **initkwargs):
|
||||
"""
|
||||
Calls .as_view() and wraps the result in a cache_page decorator.
|
||||
See https://docs.djangoproject.com/en/1.11/topics/cache/
|
||||
See https://docs.djangoproject.com/en/dev/topics/cache/
|
||||
|
||||
:param int cache_timeout: same as cache_page; set to 0 for no cache
|
||||
:param dict cache_kwargs: dictionary of kwargs to be passed to cache_page
|
||||
@@ -131,7 +131,7 @@ def get_schema_view(info=None, url=None, patterns=None, urlconf=None, public=Fal
|
||||
def without_ui(cls, cache_timeout=0, cache_kwargs=None):
|
||||
"""
|
||||
Instantiate this view with just JSON and YAML renderers, optionally wrapped with cache_page.
|
||||
See https://docs.djangoproject.com/en/1.11/topics/cache/.
|
||||
See https://docs.djangoproject.com/en/dev/topics/cache/.
|
||||
|
||||
:param int cache_timeout: same as cache_page; set to 0 for no cache
|
||||
:param dict cache_kwargs: dictionary of kwargs to be passed to cache_page
|
||||
@@ -143,7 +143,7 @@ def get_schema_view(info=None, url=None, patterns=None, urlconf=None, public=Fal
|
||||
def with_ui(cls, renderer='swagger', cache_timeout=0, cache_kwargs=None):
|
||||
"""
|
||||
Instantiate this view with a Web UI renderer, optionally wrapped with cache_page.
|
||||
See https://docs.djangoproject.com/en/1.11/topics/cache/.
|
||||
See https://docs.djangoproject.com/en/dev/topics/cache/.
|
||||
|
||||
:param str renderer: UI renderer; allowed values are ``swagger``, ``redoc``
|
||||
:param int cache_timeout: same as cache_page; set to 0 for no cache
|
||||
|
||||
Reference in New Issue
Block a user