removed old style object inheritance, super() call and python2compat decorator from utils

This commit is contained in:
Asif Saif Uddin 2018-10-25 20:27:39 +06:00
parent 87e603edca
commit b1bbbc8ce0
4 changed files with 7 additions and 9 deletions

View File

@ -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)

View File

@ -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

View File

@ -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))

View File

@ -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():