diff --git a/docs/api-guide/filtering.md b/docs/api-guide/filtering.md index 3541388ca..512acafbd 100644 --- a/docs/api-guide/filtering.md +++ b/docs/api-guide/filtering.md @@ -241,7 +241,7 @@ To dynamically change search fields based on request content, it's possible to s def get_search_fields(self, view, request): if request.query_params.get('title_only'): return ['title'] - return super(CustomSearchFilter, self).get_search_fields(view, request) + return super().get_search_fields(view, request) For more details, see the [Django documentation][search-django-admin]. diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index 377f732ac..4d032bd9e 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -1095,7 +1095,7 @@ For example, if you wanted to be able to set which fields should be used by a se fields = kwargs.pop('fields', None) # Instantiate the superclass normally - super(DynamicFieldsModelSerializer, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) if fields is not None: # Drop any fields that are not specified in the `fields` argument. diff --git a/docs/tutorial/4-authentication-and-permissions.md b/docs/tutorial/4-authentication-and-permissions.md index 79ce355c9..cb0321ea2 100644 --- a/docs/tutorial/4-authentication-and-permissions.md +++ b/docs/tutorial/4-authentication-and-permissions.md @@ -38,7 +38,7 @@ And now we can add a `.save()` method to our model class: formatter = HtmlFormatter(style=self.style, linenos=linenos, full=True, **options) self.highlighted = highlight(self.code, lexer, formatter) - super(Snippet, self).save(*args, **kwargs) + super().save(*args, **kwargs) When that's all done we'll need to update our database tables. Normally we'd create a database migration in order to do that, but for the purposes of this tutorial, let's just delete the database and start again. diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 5cafed555..d7e7816ce 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -1491,6 +1491,8 @@ class MultipleChoiceField(ChoiceField): self.fail('empty') return { + # Arguments for super() are needed because of scoping inside + # comprehensions. super(MultipleChoiceField, self).to_internal_value(item) for item in data } diff --git a/rest_framework/schemas/coreapi.py b/rest_framework/schemas/coreapi.py index 75ed5671a..179f0fa3c 100644 --- a/rest_framework/schemas/coreapi.py +++ b/rest_framework/schemas/coreapi.py @@ -58,7 +58,7 @@ class LinkNode(OrderedDict): def __init__(self): self.links = [] self.methods_counter = Counter() - super(LinkNode, self).__init__() + super().__init__() def get_available_key(self, preferred_key): if preferred_key not in self: @@ -120,7 +120,7 @@ class SchemaGenerator(BaseSchemaGenerator): assert coreapi, '`coreapi` must be installed for schema support.' assert coreschema, '`coreschema` must be installed for schema support.' - super(SchemaGenerator, self).__init__(title, url, description, patterns, urlconf) + super().__init__(title, url, description, patterns, urlconf) self.coerce_method_names = api_settings.SCHEMA_COERCE_METHOD_NAMES def get_links(self, request=None): @@ -346,7 +346,7 @@ class AutoSchema(ViewInspector): * `manual_fields`: list of `coreapi.Field` instances that will be added to auto-generated fields, overwriting on `Field.name` """ - super(AutoSchema, self).__init__() + super().__init__() if manual_fields is None: manual_fields = [] self._manual_fields = manual_fields @@ -587,7 +587,7 @@ class ManualSchema(ViewInspector): * `fields`: list of `coreapi.Field` instances. * `description`: String description for view. Optional. """ - super(ManualSchema, self).__init__() + super().__init__() assert all(isinstance(f, coreapi.Field) for f in fields), "`fields` must be a list of coreapi.Field instances" self._fields = fields self._description = description