diff --git a/polymorphic/compat.py b/polymorphic/compat.py deleted file mode 100644 index ee7f1395..00000000 --- a/polymorphic/compat.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Compatibility with Python 2 (taken from 'django.utils.six')""" - - -def with_metaclass(meta, *bases): - class metaclass(type): - def __new__(cls, name, this_bases, d): - return meta(name, bases, d) - - return type.__new__(metaclass, "temporary_class", (), {}) diff --git a/polymorphic/models.py b/polymorphic/models.py index df0cc485..4a6cadce 100644 --- a/polymorphic/models.py +++ b/polymorphic/models.py @@ -6,8 +6,6 @@ from django.db.models.fields.related import ForwardManyToOneDescriptor, ReverseOneToOneDescriptor from django.db.utils import DEFAULT_DB_ALIAS -from polymorphic.compat import with_metaclass - from .base import PolymorphicModelBase from .managers import PolymorphicManager from .query_translate import translate_polymorphic_Q_object @@ -24,7 +22,7 @@ class PolymorphicTypeInvalid(RuntimeError): pass -class PolymorphicModel(with_metaclass(PolymorphicModelBase, models.Model)): +class PolymorphicModel(models.Model, metaclass=PolymorphicModelBase): """ Abstract base class that provides polymorphic behaviour for any model directly or indirectly derived from it. diff --git a/polymorphic/query_translate.py b/polymorphic/query_translate.py index 627f1840..9e6a087a 100644 --- a/polymorphic/query_translate.py +++ b/polymorphic/query_translate.py @@ -38,7 +38,7 @@ def translate_polymorphic_filter_definitions_in_kwargs( Returns: a list of non-keyword-arguments (Q objects) to be added to the filter() query. """ additional_args = [] - for field_path, val in kwargs.copy().items(): # Python 3 needs copy + for field_path, val in kwargs.copy().items(): # `copy` so we're not mutating the dict new_expr = _translate_polymorphic_filter_definition( queryset_model, field_path, val, using=using )