1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Refs #23919 -- Stopped inheriting from object to define new style classes.

This commit is contained in:
Simon Charette
2017-01-19 02:39:46 -05:00
committed by Claude Paroz
parent a556396339
commit cecc079168
293 changed files with 512 additions and 514 deletions

View File

@@ -15,7 +15,7 @@ __all__ = ('BoundField',)
@html_safe
class BoundField(object):
class BoundField:
"A Field plus data"
def __init__(self, form, field, name):
self.form = form
@@ -251,7 +251,7 @@ class BoundField(object):
@html_safe
class BoundWidget(object):
class BoundWidget:
"""
A container class used for iterating over widgets. This is useful for
widgets that have choices. For example, the following can be used in a

View File

@@ -44,7 +44,7 @@ __all__ = (
)
class Field(object):
class Field:
widget = TextInput # Default widget to use when rendering this type of Field.
hidden_widget = HiddenInput # Default widget to use when rendering this as "hidden".
default_validators = [] # Default set of validators
@@ -755,7 +755,7 @@ class NullBooleanField(BooleanField):
pass
class CallableChoiceIterator(object):
class CallableChoiceIterator:
def __init__(self, choices_func):
self.choices_func = choices_func

View File

@@ -58,7 +58,7 @@ class DeclarativeFieldsMetaclass(MediaDefiningClass):
@html_safe
class BaseForm(object):
class BaseForm:
# This is the main implementation of all the Form logic. Note that this
# class is different than Form. See the comments by the Form class for more
# information. Any improvements to the form API should be made to *this*

View File

@@ -43,7 +43,7 @@ class ManagementForm(Form):
@html_safe
class BaseFormSet(object):
class BaseFormSet:
"""
A collection of instances of the same Form class.
"""

View File

@@ -184,7 +184,7 @@ def fields_for_model(model, fields=None, exclude=None, widgets=None,
return field_dict
class ModelFormOptions(object):
class ModelFormOptions:
def __init__(self, options=None):
self.model = getattr(options, 'model', None)
self.fields = getattr(options, 'fields', None)
@@ -517,10 +517,8 @@ def modelform_factory(model, form=ModelForm, fields=None, exclude=None,
# If parent form class already has an inner Meta, the Meta we're
# creating needs to inherit from the parent's inner meta.
parent = (object,)
if hasattr(form, 'Meta'):
parent = (form.Meta, object)
Meta = type(str('Meta'), parent, attrs)
bases = (form.Meta,) if hasattr(form, 'Meta') else ()
Meta = type(str('Meta'), bases, attrs)
if formfield_callback:
Meta.formfield_callback = staticmethod(formfield_callback)
# Give this new form class a reasonable name.
@@ -1099,7 +1097,7 @@ class InlineForeignKeyField(Field):
return False
class ModelChoiceIterator(object):
class ModelChoiceIterator:
def __init__(self, field):
self.field = field
self.queryset = field.queryset

View File

@@ -23,7 +23,7 @@ def get_default_renderer():
return renderer_class()
class BaseRenderer(object):
class BaseRenderer:
def get_template(self, template_name):
raise NotImplementedError('subclasses must implement get_template()')
@@ -32,7 +32,7 @@ class BaseRenderer(object):
return template.render(context, request=request).strip()
class EngineMixin(object):
class EngineMixin:
def get_template(self, template_name):
return self.engine.get_template(template_name)

View File

@@ -35,7 +35,7 @@ MEDIA_TYPES = ('css', 'js')
@html_safe
class Media(object):
class Media:
def __init__(self, media=None, **kwargs):
if media:
media_attrs = media.__dict__