1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Refs #23919 -- Replaced super(...) with super() in metaclasses.

This commit is contained in:
Jon Dufresne 2019-11-28 06:34:29 -08:00 committed by Carlton Gibson
parent 46a0edc3ba
commit 86a0231e0a
4 changed files with 4 additions and 4 deletions

View File

@ -30,7 +30,7 @@ class DeclarativeFieldsMetaclass(MediaDefiningClass):
attrs.pop(key) attrs.pop(key)
attrs['declared_fields'] = dict(current_fields) attrs['declared_fields'] = dict(current_fields)
new_class = super(DeclarativeFieldsMetaclass, mcs).__new__(mcs, name, bases, attrs) new_class = super().__new__(mcs, name, bases, attrs)
# Walk through the MRO. # Walk through the MRO.
declared_fields = {} declared_fields = {}

View File

@ -214,7 +214,7 @@ class ModelFormMetaclass(DeclarativeFieldsMetaclass):
formfield_callback = attrs.pop('formfield_callback', base_formfield_callback) formfield_callback = attrs.pop('formfield_callback', base_formfield_callback)
new_class = super(ModelFormMetaclass, mcs).__new__(mcs, name, bases, attrs) new_class = super().__new__(mcs, name, bases, attrs)
if bases == (BaseModelForm,): if bases == (BaseModelForm,):
return new_class return new_class

View File

@ -183,7 +183,7 @@ class MediaDefiningClass(type):
Metaclass for classes that can have media definitions. Metaclass for classes that can have media definitions.
""" """
def __new__(mcs, name, bases, attrs): def __new__(mcs, name, bases, attrs):
new_class = super(MediaDefiningClass, mcs).__new__(mcs, name, bases, attrs) new_class = super().__new__(mcs, name, bases, attrs)
if 'media' not in attrs: if 'media' not in attrs:
new_class.media = media_property(new_class) new_class.media = media_property(new_class)

View File

@ -226,7 +226,7 @@ class ModelTests(TestCase):
""" """
class HorseBase(models.base.ModelBase): class HorseBase(models.base.ModelBase):
def __init__(cls, name, bases, attrs): def __init__(cls, name, bases, attrs):
super(HorseBase, cls).__init__(name, bases, attrs) super().__init__(name, bases, attrs)
cls.horns = (1 if 'magic' in attrs else 0) cls.horns = (1 if 'magic' in attrs else 0)
class Horse(models.Model, metaclass=HorseBase): class Horse(models.Model, metaclass=HorseBase):