From dc165ec8e5698ffc6dee6b510f1f92c9fd7467fe Mon Sep 17 00:00:00 2001 From: chillaranand Date: Sun, 22 Jan 2017 12:27:14 +0530 Subject: Refs #23919 -- Replaced super(ClassName, self) with super() in docs. --- docs/ref/forms/fields.txt | 4 ++-- docs/ref/forms/validation.txt | 18 +++++++++--------- docs/ref/forms/widgets.txt | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'docs/ref/forms') diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index b135532b2d..2949ad0a9b 100644 --- a/docs/ref/forms/fields.txt +++ b/docs/ref/forms/fields.txt @@ -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`` diff --git a/docs/ref/forms/validation.txt b/docs/ref/forms/validation.txt index b57f44cb6c..6d3edf93e3 100644 --- a/docs/ref/forms/validation.txt +++ b/docs/ref/forms/validation.txt @@ -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") diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt index 210e5ce93c..9f3ea2840c 100644 --- a/docs/ref/forms/widgets.txt +++ b/docs/ref/forms/widgets.txt @@ -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: -- cgit v1.3