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

This commit is contained in:
chillaranand 2017-01-22 12:27:14 +05:30 committed by Tim Graham
parent 2d96c027f5
commit dc165ec8e5
36 changed files with 103 additions and 104 deletions

View file

@ -1029,7 +1029,7 @@ Slightly complex built-in ``Field`` classes
required=False,
),
)
super(PhoneField, self).__init__(
super().__init__(
error_messages=error_messages, fields=fields,
require_all_fields=False, *args, **kwargs
)
@ -1100,7 +1100,7 @@ method::
foo_select = forms.ModelMultipleChoiceField(queryset=None)
def __init__(self, *args, **kwargs):
super(FooMultipleChoiceForm, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.fields['foo_select'].queryset = ...
``ModelChoiceField``

View file

@ -272,7 +272,7 @@ containing comma-separated email addresses. The full class looks like this::
def validate(self, value):
"""Check if value consists only of valid emails."""
# Use the parent's handling of required fields, etc.
super(MultiEmailField, self).validate(value)
super().validate(value)
for email in value:
validate_email(email)
@ -352,7 +352,7 @@ example::
...
def clean(self):
cleaned_data = super(ContactForm, self).clean()
cleaned_data = super().clean()
cc_myself = cleaned_data.get("cc_myself")
subject = cleaned_data.get("subject")
@ -367,14 +367,14 @@ example::
In this code, if the validation error is raised, the form will display an
error message at the top of the form (normally) describing the problem.
The call to ``super(ContactForm, self).clean()`` in the example code ensures
that any validation logic in parent classes is maintained. If your form
inherits another that doesn't return a ``cleaned_data`` dictionary in its
``clean()`` method (doing so is optional), then don't assign ``cleaned_data``
to the result of the ``super()`` call and use ``self.cleaned_data`` instead::
The call to ``super().clean()`` in the example code ensures that any validation
logic in parent classes is maintained. If your form inherits another that
doesn't return a ``cleaned_data`` dictionary in its ``clean()`` method (doing
so is optional), then don't assign ``cleaned_data`` to the result of the
``super()`` call and use ``self.cleaned_data`` instead::
def clean(self):
super(ContactForm, self).clean()
super().clean()
cc_myself = self.cleaned_data.get("cc_myself")
...
@ -393,7 +393,7 @@ work out what works effectively in your particular situation. Our new code
...
def clean(self):
cleaned_data = super(ContactForm, self).clean()
cleaned_data = super().clean()
cc_myself = cleaned_data.get("cc_myself")
subject = cleaned_data.get("subject")

View file

@ -410,7 +410,7 @@ foundation for custom widgets.
widgets.Select(attrs=attrs, choices=months),
widgets.Select(attrs=attrs, choices=years),
)
super(DateSelectorWidget, self).__init__(_widgets, attrs)
super().__init__(_widgets, attrs)
def decompress(self, value):
if value: