Skip to content

Commit 8ea4932

Browse files
committed
Remove unnecessary Python version compatibility bits
1 parent bd18ac5 commit 8ea4932

File tree

5 files changed

+3
-16
lines changed

5 files changed

+3
-16
lines changed

polymorphic/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ class PolymorphicModelBase(ModelBase):
5252
"""
5353

5454
def __new__(self, model_name, bases, attrs, **kwargs):
55-
# print; print '###', model_name, '- bases:', bases
56-
5755
# Workaround compatibility issue with six.with_metaclass() and custom Django model metaclasses:
5856
if not attrs and model_name == "NewBase":
5957
return super().__new__(self, model_name, bases, attrs, **kwargs)

polymorphic/compat.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

polymorphic/models.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from django.db.models.fields.related import ForwardManyToOneDescriptor, ReverseOneToOneDescriptor
77
from django.db.utils import DEFAULT_DB_ALIAS
88

9-
from polymorphic.compat import with_metaclass
10-
119
from .base import PolymorphicModelBase
1210
from .managers import PolymorphicManager
1311
from .query_translate import translate_polymorphic_Q_object
@@ -24,7 +22,7 @@ class PolymorphicTypeInvalid(RuntimeError):
2422
pass
2523

2624

27-
class PolymorphicModel(with_metaclass(PolymorphicModelBase, models.Model)):
25+
class PolymorphicModel(models.Model, metaclass=PolymorphicModelBase):
2826
"""
2927
Abstract base class that provides polymorphic behaviour
3028
for any model directly or indirectly derived from it.

polymorphic/query_translate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def translate_polymorphic_filter_definitions_in_kwargs(
3838
Returns: a list of non-keyword-arguments (Q objects) to be added to the filter() query.
3939
"""
4040
additional_args = []
41-
for field_path, val in kwargs.copy().items(): # Python 3 needs copy
41+
for field_path, val in kwargs.copy().items(): # `copy` so we're not mutating the dict
4242
new_expr = _translate_polymorphic_filter_definition(
4343
queryset_model, field_path, val, using=using
4444
)

polymorphic/tests/test_orm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from django.db.utils import IntegrityError
99
from django.test import TransactionTestCase
1010

11-
from polymorphic import compat, query_translate
11+
from polymorphic import query_translate
1212
from polymorphic.managers import PolymorphicManager
1313
from polymorphic.models import PolymorphicTypeInvalid, PolymorphicTypeUndefined
1414
from polymorphic.tests.models import (

0 commit comments

Comments
 (0)