mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-31 18:40:07 +03:00
removed old style object inheritance, super() call and python2compat decorator from utils
This commit is contained in:
parent
87e603edca
commit
b1bbbc8ce0
|
@ -63,4 +63,4 @@ class JSONEncoder(json.JSONEncoder):
|
|||
pass
|
||||
elif hasattr(obj, '__iter__'):
|
||||
return tuple(item for item in obj)
|
||||
return super(JSONEncoder, self).default(obj)
|
||||
return super().default(obj)
|
||||
|
|
|
@ -16,7 +16,7 @@ NUMERIC_FIELD_TYPES = (
|
|||
)
|
||||
|
||||
|
||||
class ClassLookupDict(object):
|
||||
class ClassLookupDict:
|
||||
"""
|
||||
Takes a dictionary with classes as keys.
|
||||
Lookups against this object will traverses the object's inheritance
|
||||
|
|
|
@ -5,7 +5,6 @@ See https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7
|
|||
"""
|
||||
|
||||
from django.http.multipartparser import parse_header
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
from rest_framework import HTTP_HEADER_ENCODING
|
||||
|
||||
|
@ -45,8 +44,7 @@ def order_by_precedence(media_type_lst):
|
|||
return [media_types for media_types in ret if media_types]
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class _MediaType(object):
|
||||
class _MediaType:
|
||||
def __init__(self, media_type_str):
|
||||
self.orig = '' if (media_type_str is None) else media_type_str
|
||||
self.full_type, self.params = parse_header(self.orig.encode(HTTP_HEADER_ENCODING))
|
||||
|
|
|
@ -16,7 +16,7 @@ class ReturnDict(OrderedDict):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.serializer = kwargs.pop('serializer')
|
||||
super(ReturnDict, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def copy(self):
|
||||
return ReturnDict(self, serializer=self.serializer)
|
||||
|
@ -39,7 +39,7 @@ class ReturnList(list):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.serializer = kwargs.pop('serializer')
|
||||
super(ReturnList, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def __repr__(self):
|
||||
return list.__repr__(self)
|
||||
|
@ -50,7 +50,7 @@ class ReturnList(list):
|
|||
return (list, (list(self),))
|
||||
|
||||
|
||||
class BoundField(object):
|
||||
class BoundField:
|
||||
"""
|
||||
A field object that also includes `.value` and `.error` properties.
|
||||
Returned when iterating over a serializer instance,
|
||||
|
@ -104,7 +104,7 @@ class NestedBoundField(BoundField):
|
|||
def __init__(self, field, value, errors, prefix=''):
|
||||
if value is None or value is '':
|
||||
value = {}
|
||||
super(NestedBoundField, self).__init__(field, value, errors, prefix)
|
||||
super().__init__(field, value, errors, prefix)
|
||||
|
||||
def __iter__(self):
|
||||
for field in self.fields.values():
|
||||
|
|
Loading…
Reference in New Issue
Block a user