diff --git a/src/drf_yasg/openapi.py b/src/drf_yasg/openapi.py index 5dc4b414..0a2cfb8f 100644 --- a/src/drf_yasg/openapi.py +++ b/src/drf_yasg/openapi.py @@ -2,8 +2,7 @@ import logging import re import urllib.parse as urlparse -from collections import OrderedDict -from collections import abc as collections_abc +from collections import OrderedDict, abc as collections_abc from django.urls import get_script_prefix from django.utils.functional import Promise @@ -89,7 +88,7 @@ class SwaggerDict(OrderedDict): def __init__(self, **attrs): super(SwaggerDict, self).__init__() self._extras__ = attrs - if isinstance(self, SwaggerDict): + if type(self) == SwaggerDict: self._insert_extras__() def __setattr__(self, key, value): @@ -517,7 +516,7 @@ def __init__(self, resolver, name, scope, expected_type, ignore_unresolved=False :param bool ignore_unresolved: do not throw if the referenced object does not exist """ super(_Ref, self).__init__() - assert type(self) != _Ref, "do not instantiate _Ref directly" # noqa: E721 + assert not type(self) == _Ref, "do not instantiate _Ref directly" ref_name = "#/{scope}/{name}".format(scope=scope, name=name) if not ignore_unresolved: obj = resolver.get(name, scope)