Skip to content

Commit e4df1bc

Browse files
committed
convert super to Python3 style
1 parent db42662 commit e4df1bc

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

hashid_field/field.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ def __init__(self, salt=settings.HASHID_FIELD_SALT, min_length=7, alphabet=Hashi
3333
allow_int_lookup = kwargs['allow_int']
3434
del kwargs['allow_int']
3535
self.allow_int_lookup = allow_int_lookup
36-
super(HashidFieldMixin, self).__init__(*args, **kwargs)
36+
super().__init__(*args, **kwargs)
3737

3838
def deconstruct(self):
39-
name, path, args, kwargs = super(HashidFieldMixin, self).deconstruct()
39+
name, path, args, kwargs = super().deconstruct()
4040
kwargs['min_length'] = self.min_length
4141
kwargs['alphabet'] = self.alphabet
4242
return name, path, args, kwargs
4343

4444
def check(self, **kwargs):
45-
errors = super(HashidFieldMixin, self).check(**kwargs)
45+
errors = super().check(**kwargs)
4646
errors.extend(self._check_alphabet_min_length())
4747
errors.extend(self._check_salt_is_set())
4848
return errors
@@ -91,7 +91,7 @@ def get_lookup(self, lookup_name):
9191
if lookup_name in self.iterable_lookups:
9292
return HashidIterableLookup
9393
if lookup_name in self.passthrough_lookups:
94-
return super(HashidFieldMixin, self).get_lookup(lookup_name)
94+
return super().get_lookup(lookup_name)
9595
return None # Otherwise, we don't allow lookups of this type
9696

9797
def to_python(self, value):
@@ -121,7 +121,7 @@ def get_prep_value(self, value):
121121
return hashid.id
122122

123123
def contribute_to_class(self, cls, name, **kwargs):
124-
super(HashidFieldMixin, self).contribute_to_class(cls, name, **kwargs)
124+
super().contribute_to_class(cls, name, **kwargs)
125125
# setattr(cls, "_" + self.attname, getattr(cls, self.attname))
126126
setattr(cls, self.attname, HashidDescriptor(self.attname, salt=self.salt, min_length=self.min_length, alphabet=self.alphabet))
127127

@@ -134,7 +134,7 @@ def formfield(self, **kwargs):
134134
defaults.update(kwargs)
135135
if defaults.get('widget') == admin_widgets.AdminIntegerFieldWidget:
136136
defaults['widget'] = admin_widgets.AdminTextInputWidget
137-
return super(HashidField, self).formfield(**defaults)
137+
return super().formfield(**defaults)
138138

139139

140140
class HashidAutoField(HashidFieldMixin, models.AutoField):

hashid_field/lookups.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class HashidIterableLookup(HashidLookup):
120120

121121
def get_prep_lookup(self):
122122
if django.VERSION[0] <= 1 and django.VERSION[1] <= 8:
123-
return super(HashidIterableLookup, self).get_prep_lookup()
123+
return super().get_prep_lookup()
124124
prepared_values = []
125125
if hasattr(self.rhs, '_prepare'):
126126
# A subquery is like an iterable but its items shouldn't be
@@ -157,7 +157,7 @@ def process_rhs(self, compiler, connection):
157157
placeholder = '(' + ', '.join(sqls) + ')'
158158
return (placeholder, sqls_params)
159159
else:
160-
return super(HashidIterableLookup, self).process_rhs(compiler, connection)
160+
return super().process_rhs(compiler, connection)
161161

162162
def resolve_expression_parameter(self, compiler, connection, sql, param):
163163
params = [param]
@@ -168,7 +168,7 @@ def resolve_expression_parameter(self, compiler, connection, sql, param):
168168
return sql, params
169169

170170
def batch_process_rhs(self, compiler, connection, rhs=None):
171-
pre_processed = super(HashidIterableLookup, self).batch_process_rhs(compiler, connection, rhs)
171+
pre_processed = super().batch_process_rhs(compiler, connection, rhs)
172172
# The params list may contain expressions which compile to a
173173
# sql/param pair. Zip them to get sql and param pairs that refer to the
174174
# same argument and attempt to replace them with the result of

hashid_field/rest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class UnconfiguredHashidSerialField(fields.Field):
1212
def bind(self, field_name, parent):
13-
super(UnconfiguredHashidSerialField, self).bind(field_name, parent)
13+
super().bind(field_name, parent)
1414
raise exceptions.ImproperlyConfigured(
1515
"The field '{field_name}' on {parent} must be explicitly declared when used with a ModelSerializer".format(
1616
field_name=field_name, parent=parent.__class__.__name__))
@@ -39,11 +39,11 @@ def __init__(self, **kwargs):
3939
self.hashid_salt, self.hashid_min_length, self.hashid_alphabet = \
4040
source_field.salt, source_field.min_length, source_field.alphabet
4141

42-
super(HashidSerializerMixin, self).__init__(**kwargs)
42+
super().__init__(**kwargs)
4343

4444
def to_internal_value(self, data):
4545
try:
46-
value = super(HashidSerializerMixin, self).to_internal_value(data)
46+
value = super().to_internal_value(data)
4747
return Hashid(value, salt=self.hashid_salt, min_length=self.hashid_min_length, alphabet=self.hashid_alphabet)
4848
except ValueError:
4949
raise serializers.ValidationError("Invalid int or Hashid string")

0 commit comments

Comments
 (0)