Skip to content

Commit

Permalink
Remove Python 2 compatibility code
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscouzo committed Sep 7, 2020
1 parent fdb448c commit 8e27704
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
8 changes: 4 additions & 4 deletions rest_framework_gis/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GeometryField(Field):
def __init__(self, precision=None, remove_duplicates=False, **kwargs):
self.precision = precision
self.remove_dupes = remove_duplicates
super(GeometryField, self).__init__(**kwargs)
super().__init__(**kwargs)
self.style.setdefault('base_template', 'textarea.html')

def to_representation(self, value):
Expand Down Expand Up @@ -71,7 +71,7 @@ def to_internal_value(self, value):
def validate_empty_values(self, data):
if data == '':
self.fail('required')
return super(GeometryField, self).validate_empty_values(data)
return super().validate_empty_values(data)

def _recursive_round(self, value, precision):
"""
Expand Down Expand Up @@ -109,7 +109,7 @@ def _rm_redundant_points(self, geometry, geo_type):

class GeometrySerializerMethodField(SerializerMethodField):
def to_representation(self, value):
value = super(GeometrySerializerMethodField, self).to_representation(value)
value = super().to_representation(value)
if value is not None:
# we expect value to be a GEOSGeometry instance
return GeoJsonDict(value.geojson)
Expand All @@ -134,7 +134,7 @@ def __init__(self, *args, **kwargs):
args = (geojson,)
except ValueError:
pass
super(GeoJsonDict, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def __str__(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions rest_framework_gis/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class GeometryFilter(django_filters.Filter):

def __init__(self, *args, **kwargs):
kwargs.setdefault('widget', forms.TextInput)
super(GeometryFilter, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)


class GeoFilterSet(django_filters.FilterSet):
Expand All @@ -107,7 +107,7 @@ def __new__(cls, *args, **kwargs):
except AttributeError: # pragma: nocover
cls.filter_overrides.update(cls.GEOFILTER_FOR_DBFIELD_DEFAULTS)
cls.LOOKUP_TYPES = sorted(gis_lookups)
return super(GeoFilterSet, cls).__new__(cls)
return super().__new__(cls)


class TMSTileFilter(InBBoxFilter):
Expand Down
21 changes: 8 additions & 13 deletions rest_framework_gis/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ def to_representation(self, data):
return OrderedDict(
(
("type", "FeatureCollection"),
(
"features",
super(GeoFeatureModelListSerializer, self).to_representation(data),
),
("features", super().to_representation(data)),
)
)

Expand All @@ -49,13 +46,11 @@ def many_init(cls, *args, **kwargs):
child_serializer = cls(*args, **kwargs)
list_kwargs = {'child': child_serializer}
list_kwargs.update(
dict(
[
(key, value)
for key, value in kwargs.items()
if key in LIST_SERIALIZER_KWARGS
]
)
{
key: value
for key, value in kwargs.items()
if key in LIST_SERIALIZER_KWARGS
}
)
meta = getattr(cls, 'Meta', None)
list_serializer_class = getattr(
Expand All @@ -64,7 +59,7 @@ def many_init(cls, *args, **kwargs):
return list_serializer_class(*args, **list_kwargs)

def __init__(self, *args, **kwargs):
super(GeoFeatureModelSerializer, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
meta = getattr(self, 'Meta')
default_id_field = None
primary_key = self.Meta.model._meta.pk.name
Expand Down Expand Up @@ -198,7 +193,7 @@ def to_internal_value(self, data):
"""
if 'properties' in data:
data = self.unformat_geojson(data)
return super(GeoFeatureModelSerializer, self).to_internal_value(data)
return super().to_internal_value(data)

def unformat_geojson(self, feature):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/django_restframework_gis_tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def clean(self):

def save(self, *args, **kwargs):
self._generate_slug()
super(BaseModel, self).save(*args, **kwargs)
super().save(*args, **kwargs)


class Location(BaseModel):
Expand Down

0 comments on commit 8e27704

Please sign in to comment.