New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refs #23919 -- Replaced super(ClassName, self) with super() #7905

Merged
merged 1 commit into from Jan 25, 2017
The table of contents is too big for display.
+1,221 −1,296
Diff settings

Always

Just for now

Refs #23919 -- Replaced super(ClassName, self) with super().

  • Loading branch information...
ChillarAnand authored and timgraham committed Jan 21, 2017
commit d6eaf7c0183cd04b78f2a55e1d60bb7e59598310
View
@@ -67,13 +67,13 @@ def __setattr__(self, name, value):
self.__dict__.clear()
else:
self.__dict__.pop(name, None)
super(LazySettings, self).__setattr__(name, value)
super().__setattr__(name, value)
def __delattr__(self, name):
"""
Delete a setting and clear it from cache if needed.
"""
super(LazySettings, self).__delattr__(name)
super().__delattr__(name)
self.__dict__.pop(name, None)
def configure(self, default_settings=global_settings, **options):
@@ -173,12 +173,12 @@ def __getattr__(self, name):
def __setattr__(self, name, value):
self._deleted.discard(name)
super(UserSettingsHolder, self).__setattr__(name, value)
super().__setattr__(name, value)
def __delattr__(self, name):
self._deleted.add(name)
if hasattr(self, name):
super(UserSettingsHolder, self).__delattr__(name)
super().__delattr__(name)
def __dir__(self):
return sorted(
@@ -19,5 +19,5 @@ class AdminConfig(SimpleAdminConfig):
"""The default AppConfig for admin which does autodiscovery."""
def ready(self):
super(AdminConfig, self).ready()
super().ready()
self.module.autodiscover()
@@ -513,7 +513,7 @@ def _check_readonly_fields_item(self, obj, model, field_name, label):
class ModelAdminChecks(BaseModelAdminChecks):
def check(self, admin_obj, **kwargs):
errors = super(ModelAdminChecks, self).check(admin_obj)
errors = super().check(admin_obj)
errors.extend(self._check_save_as(admin_obj))
errors.extend(self._check_save_on_top(admin_obj))
errors.extend(self._check_inlines(admin_obj))
@@ -866,7 +866,7 @@ def _check_date_hierarchy(self, obj):
class InlineModelAdminChecks(BaseModelAdminChecks):
def check(self, inline_obj, **kwargs):
errors = super(InlineModelAdminChecks, self).check(inline_obj)
errors = super().check(inline_obj)
parent_model = inline_obj.parent_model
errors.extend(self._check_relation(inline_obj, parent_model))
errors.extend(self._check_exclude_of_parent_model(inline_obj, parent_model))
@@ -879,7 +879,7 @@ def check(self, inline_obj, **kwargs):
def _check_exclude_of_parent_model(self, obj, parent_model):
# Do not perform more specific checks if the base checks result in an
# error.
errors = super(InlineModelAdminChecks, self)._check_exclude(obj)
errors = super()._check_exclude(obj)
if errors:
return []
@@ -64,8 +64,7 @@ class SimpleListFilter(ListFilter):
parameter_name = None
def __init__(self, request, params, model, model_admin):
super(SimpleListFilter, self).__init__(
request, params, model, model_admin)
super().__init__(request, params, model, model_admin)
if self.parameter_name is None:
raise ImproperlyConfigured(
"The list filter '%s' does not specify "
@@ -122,8 +121,7 @@ def __init__(self, field, request, params, model, model_admin, field_path):
self.field = field
self.field_path = field_path
self.title = getattr(field, 'verbose_name', field_path)
super(FieldListFilter, self).__init__(
request, params, model, model_admin)
super().__init__(request, params, model, model_admin)
for p in self.expected_parameters():
if p in params:
value = params.pop(p)
@@ -165,8 +163,7 @@ def __init__(self, field, request, params, model, model_admin, field_path):
self.lookup_kwarg_isnull = '%s__isnull' % field_path
self.lookup_val = request.GET.get(self.lookup_kwarg)
self.lookup_val_isnull = request.GET.get(self.lookup_kwarg_isnull)
super(RelatedFieldListFilter, self).__init__(
field, request, params, model, model_admin, field_path)
super().__init__(field, request, params, model, model_admin, field_path)
self.lookup_choices = self.field_choices(field, request, model_admin)
if hasattr(field, 'verbose_name'):
self.lookup_title = field.verbose_name
@@ -232,7 +229,7 @@ def __init__(self, field, request, params, model, model_admin, field_path):
self.lookup_kwarg2 = '%s__isnull' % field_path
self.lookup_val = request.GET.get(self.lookup_kwarg)
self.lookup_val2 = request.GET.get(self.lookup_kwarg2)
super(BooleanFieldListFilter, self).__init__(field, request, params, model, model_admin, field_path)
super().__init__(field, request, params, model, model_admin, field_path)
if (self.used_parameters and self.lookup_kwarg in self.used_parameters and
self.used_parameters[self.lookup_kwarg] in ('1', '0')):
self.used_parameters[self.lookup_kwarg] = bool(int(self.used_parameters[self.lookup_kwarg]))
@@ -274,8 +271,7 @@ def __init__(self, field, request, params, model, model_admin, field_path):
self.lookup_kwarg_isnull = '%s__isnull' % field_path
self.lookup_val = request.GET.get(self.lookup_kwarg)
self.lookup_val_isnull = request.GET.get(self.lookup_kwarg_isnull)
super(ChoicesFieldListFilter, self).__init__(
field, request, params, model, model_admin, field_path)
super().__init__(field, request, params, model, model_admin, field_path)
def expected_parameters(self):
return [self.lookup_kwarg, self.lookup_kwarg_isnull]
@@ -362,8 +358,7 @@ def __init__(self, field, request, params, model, model_admin, field_path):
(_('No date'), {self.field_generic + 'isnull': 'True'}),
(_('Has date'), {self.field_generic + 'isnull': 'False'}),
)
super(DateFieldListFilter, self).__init__(
field, request, params, model, model_admin, field_path)
super().__init__(field, request, params, model, model_admin, field_path)
def expected_parameters(self):
params = [self.lookup_kwarg_since, self.lookup_kwarg_until]
@@ -404,8 +399,7 @@ def __init__(self, field, request, params, model, model_admin, field_path):
.distinct()
.order_by(field.name)
.values_list(field.name, flat=True))
super(AllValuesFieldListFilter, self).__init__(
field, request, params, model, model_admin, field_path)
super().__init__(field, request, params, model, model_admin, field_path)
def expected_parameters(self):
return [self.lookup_kwarg, self.lookup_kwarg_isnull]
@@ -324,7 +324,7 @@ def __init__(self, formset, form, fieldsets, prepopulated_fields, original,
self.original = original
self.show_url = original and view_on_site_url is not None
self.absolute_url = view_on_site_url
super(InlineAdminForm, self).__init__(form, fieldsets, prepopulated_fields, readonly_fields, model_admin)
super().__init__(form, fieldsets, prepopulated_fields, readonly_fields, model_admin)
def __iter__(self):
for name, options in self.fieldsets:
@@ -366,7 +366,7 @@ def ordering_field(self):
class InlineFieldset(Fieldset):
def __init__(self, formset, *args, **kwargs):
self.formset = formset
super(InlineFieldset, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
def __iter__(self):
fk = getattr(self.formset, "fk", None)
@@ -381,7 +381,7 @@ class AdminErrorList(forms.utils.ErrorList):
Stores all errors for the form/formsets in an add/change stage view.
"""
def __init__(self, form, inline_formsets):
super(AdminErrorList, self).__init__()
super().__init__()
if form.is_bound:
self.extend(form.errors.values())
@@ -519,7 +519,7 @@ def __init__(self, model, admin_site):
self.model = model
self.opts = model._meta
self.admin_site = admin_site
super(ModelAdmin, self).__init__()
super().__init__()
def __str__(self):
return "%s.%s" % (self.model._meta.app_label, self.__class__.__name__)
@@ -1842,7 +1842,7 @@ def __init__(self, parent_model, admin_site):
self.parent_model = parent_model
self.opts = self.model._meta
self.has_registered_model = admin_site.is_registered(self.model)
super(InlineModelAdmin, self).__init__()
super().__init__()
if self.verbose_name is None:
self.verbose_name = self.model._meta.verbose_name
if self.verbose_name_plural is None:
@@ -1936,7 +1936,7 @@ def hand_clean_DELETE(self):
raise ValidationError(msg, code='deleting_protected', params=params)
def is_valid(self):
result = super(DeleteProtectedModelForm, self).is_valid()
result = super().is_valid()
self.hand_clean_DELETE()
return result
@@ -1954,7 +1954,7 @@ def get_fields(self, request, obj=None):
return list(form.base_fields) + list(self.get_readonly_fields(request, obj))
def get_queryset(self, request):
queryset = super(InlineModelAdmin, self).get_queryset(request)
queryset = super().get_queryset(request)
if not self.has_change_permission(request):
queryset = queryset.none()
return queryset
@@ -1966,7 +1966,7 @@ def has_add_permission(self, request):
# to have the change permission for the related model in order to
# be able to do anything with the intermediate model.
return self.has_change_permission(request)
return super(InlineModelAdmin, self).has_add_permission(request)
return super().has_add_permission(request)
def has_change_permission(self, request, obj=None):
opts = self.opts
@@ -1987,7 +1987,7 @@ def has_delete_permission(self, request, obj=None):
# to have the change permission for the related model in order to
# be able to do anything with the intermediate model.
return self.has_change_permission(request, obj)
return super(InlineModelAdmin, self).has_delete_permission(request, obj)
return super().has_delete_permission(request, obj)
class StackedInline(InlineModelAdmin):
@@ -198,7 +198,7 @@ class MyAdminSite(AdminSite):
def get_urls(self):
from django.conf.urls import url
urls = super(MyAdminSite, self).get_urls()
urls = super().get_urls()
urls += [
url(r'^my_view/$', self.admin_view(some_view))
]
@@ -291,7 +291,7 @@ class ResultList(list):
# compatibility with existing admin templates.
def __init__(self, form, *items):
self.form = form
super(ResultList, self).__init__(*items)
super().__init__(*items)
def results(cl):
@@ -175,7 +175,7 @@ def format_callback(obj):
class NestedObjects(Collector):
def __init__(self, *args, **kwargs):
super(NestedObjects, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.edges = {} # {from_instance: [to_instances]}
self.protected = set()
self.model_objs = defaultdict(set)
@@ -195,12 +195,12 @@ def collect(self, objs, source=None, source_attr=None, **kwargs):
self.add_edge(None, obj)
self.model_objs[obj._meta.model].add(obj)
try:
return super(NestedObjects, self).collect(objs, source_attr=source_attr, **kwargs)
return super().collect(objs, source_attr=source_attr, **kwargs)
except models.ProtectedError as e:
self.protected.update(e.protected_objects)
def related_objects(self, related, objs):
qs = super(NestedObjects, self).related_objects(related, objs)
qs = super().related_objects(related, objs)
return qs.select_related(related.field.name)
def _nested(self, obj, seen, format_callback):
@@ -29,10 +29,10 @@ def media(self):
def __init__(self, verbose_name, is_stacked, attrs=None, choices=()):
self.verbose_name = verbose_name
self.is_stacked = is_stacked
super(FilteredSelectMultiple, self).__init__(attrs, choices)
super().__init__(attrs, choices)
def get_context(self, name, value, attrs=None):
context = super(FilteredSelectMultiple, self).get_context(name, value, attrs)
context = super().get_context(name, value, attrs)
context['widget']['attrs']['class'] = 'selectfilter'
if self.is_stacked:
context['widget']['attrs']['class'] += 'stacked'
@@ -51,7 +51,7 @@ def __init__(self, attrs=None, format=None):
final_attrs = {'class': 'vDateField', 'size': '10'}
if attrs is not None:
final_attrs.update(attrs)
super(AdminDateWidget, self).__init__(attrs=final_attrs, format=format)
super().__init__(attrs=final_attrs, format=format)
class AdminTimeWidget(forms.TimeInput):
@@ -64,7 +64,7 @@ def __init__(self, attrs=None, format=None):
final_attrs = {'class': 'vTimeField', 'size': '8'}
if attrs is not None:
final_attrs.update(attrs)
super(AdminTimeWidget, self).__init__(attrs=final_attrs, format=format)
super().__init__(attrs=final_attrs, format=format)
class AdminSplitDateTime(forms.SplitDateTimeWidget):
@@ -80,7 +80,7 @@ def __init__(self, attrs=None):
forms.MultiWidget.__init__(self, widgets, attrs)
def get_context(self, name, value, attrs):
context = super(AdminSplitDateTime, self).get_context(name, value, attrs)
context = super().get_context(name, value, attrs)
context['date_label'] = _('Date:')
context['time_label'] = _('Time:')
return context
@@ -127,10 +127,10 @@ def __init__(self, rel, admin_site, attrs=None, using=None):
self.rel = rel
self.admin_site = admin_site
self.db = using
super(ForeignKeyRawIdWidget, self).__init__(attrs)
super().__init__(attrs)
def get_context(self, name, value, attrs=None):
context = super(ForeignKeyRawIdWidget, self).get_context(name, value, attrs)
context = super().get_context(name, value, attrs)
rel_to = self.rel.model
if rel_to in self.admin_site._registry:
# The related object is registered with the same AdminSite
@@ -197,7 +197,7 @@ class ManyToManyRawIdWidget(ForeignKeyRawIdWidget):
template_name = 'admin/widgets/many_to_many_raw_id.html'
def get_context(self, name, value, attrs=None):
context = super(ManyToManyRawIdWidget, self).get_context(name, value, attrs)
context = super().get_context(name, value, attrs)
if self.rel.model in self.admin_site._registry:
# The related object is registered with the same AdminSite
context['widget']['attrs']['class'] = 'vManyToManyRawIdAdminField'
@@ -310,23 +310,23 @@ def __init__(self, attrs=None):
final_attrs = {'class': 'vLargeTextField'}
if attrs is not None:
final_attrs.update(attrs)
super(AdminTextareaWidget, self).__init__(attrs=final_attrs)
super().__init__(attrs=final_attrs)
class AdminTextInputWidget(forms.TextInput):
def __init__(self, attrs=None):
final_attrs = {'class': 'vTextField'}
if attrs is not None:
final_attrs.update(attrs)
super(AdminTextInputWidget, self).__init__(attrs=final_attrs)
super().__init__(attrs=final_attrs)
class AdminEmailInputWidget(forms.EmailInput):
def __init__(self, attrs=None):
final_attrs = {'class': 'vTextField'}
if attrs is not None:
final_attrs.update(attrs)
super(AdminEmailInputWidget, self).__init__(attrs=final_attrs)
super().__init__(attrs=final_attrs)
class AdminURLFieldWidget(forms.URLInput):
@@ -336,17 +336,17 @@ def __init__(self, attrs=None):
final_attrs = {'class': 'vURLField'}
if attrs is not None:
final_attrs.update(attrs)
super(AdminURLFieldWidget, self).__init__(attrs=final_attrs)
super().__init__(attrs=final_attrs)
def get_context(self, name, value, attrs):
context = super(AdminURLFieldWidget, self).get_context(name, value, attrs)
context = super().get_context(name, value, attrs)
context['current_label'] = _('Currently:')
context['change_label'] = _('Change:')
context['widget']['href'] = smart_urlquote(context['widget']['value'])
return context
def format_value(self, value):
value = super(AdminURLFieldWidget, self).format_value(value)
value = super().format_value(value)
return force_text(value)
@@ -357,7 +357,7 @@ def __init__(self, attrs=None):
final_attrs = {'class': self.class_name}
if attrs is not None:
final_attrs.update(attrs)
super(AdminIntegerFieldWidget, self).__init__(attrs=final_attrs)
super().__init__(attrs=final_attrs)
class AdminBigIntegerFieldWidget(AdminIntegerFieldWidget):
Oops, something went wrong.