mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-01 11:00:13 +03:00
removed old style object inheritance and super() call from authtocken and schemas
This commit is contained in:
parent
d00211b905
commit
87e603edca
|
@ -30,7 +30,7 @@ class Token(models.Model):
|
|||
def save(self, *args, **kwargs):
|
||||
if not self.key:
|
||||
self.key = self.generate_key()
|
||||
return super(Token, self).save(*args, **kwargs)
|
||||
return super().save(*args, **kwargs)
|
||||
|
||||
def generate_key(self):
|
||||
return binascii.hexlify(os.urandom(20)).decode()
|
||||
|
|
|
@ -68,7 +68,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:
|
||||
|
@ -140,7 +140,7 @@ _PATH_PARAMETER_COMPONENT_RE = re.compile(
|
|||
)
|
||||
|
||||
|
||||
class EndpointEnumerator(object):
|
||||
class EndpointEnumerator:
|
||||
"""
|
||||
A class to determine the available API endpoints that a project exposes.
|
||||
"""
|
||||
|
@ -232,7 +232,7 @@ class EndpointEnumerator(object):
|
|||
return [method for method in methods if method not in ('OPTIONS', 'HEAD')]
|
||||
|
||||
|
||||
class SchemaGenerator(object):
|
||||
class SchemaGenerator:
|
||||
# Map HTTP methods onto actions.
|
||||
default_mapping = {
|
||||
'get': 'retrieve',
|
||||
|
|
|
@ -122,7 +122,7 @@ def get_pk_description(model, model_field):
|
|||
)
|
||||
|
||||
|
||||
class ViewInspector(object):
|
||||
class ViewInspector:
|
||||
"""
|
||||
Descriptor class on APIView.
|
||||
|
||||
|
@ -201,7 +201,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
|
||||
|
@ -469,7 +469,7 @@ class ManualSchema(ViewInspector):
|
|||
* `fields`: list of `coreapi.Field` instances.
|
||||
* `descripton`: 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
|
||||
|
@ -492,7 +492,7 @@ class ManualSchema(ViewInspector):
|
|||
class DefaultSchema(ViewInspector):
|
||||
"""Allows overriding AutoSchema using DEFAULT_SCHEMA_CLASS setting"""
|
||||
def __get__(self, instance, owner):
|
||||
result = super(DefaultSchema, self).__get__(instance, owner)
|
||||
result = super().__get__(instance, owner)
|
||||
if not isinstance(result, DefaultSchema):
|
||||
return result
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class SchemaView(APIView):
|
|||
public = False
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SchemaView, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
if self.renderer_classes is None:
|
||||
self.renderer_classes = [
|
||||
renderers.OpenAPIRenderer,
|
||||
|
|
Loading…
Reference in New Issue
Block a user