Skip to content

Commit

Permalink
Python 2 cleanups (#1186)
Browse files Browse the repository at this point in the history
* Remove explicit inheritance from `object`
* Use argumentless super() syntax

Co-authored-by: Ryan P Kilby <kilbyr@gmail.com>
  • Loading branch information
kaedroho and rpkilby committed May 14, 2020
1 parent 1880430 commit eca2c1f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion django_filters/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def is_callable(value):
return callable(value) and not isinstance(value, type)


class Settings(object):
class Settings:

def __getattr__(self, name):
if name not in DEFAULTS:
Expand Down
4 changes: 2 additions & 2 deletions django_filters/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def clean(self, value):
return value


class ChoiceIterator(object):
class ChoiceIterator:
# Emulates the behavior of ModelChoiceIterator, but instead wraps
# the field's _choices iterable.

Expand Down Expand Up @@ -257,7 +257,7 @@ def __len__(self):
return super().__len__() + add


class ChoiceIteratorMixin(object):
class ChoiceIteratorMixin:
def __init__(self, *args, **kwargs):
self.null_label = kwargs.pop('null_label', settings.NULL_CHOICE_LABEL)
self.null_value = kwargs.pop('null_value', settings.NULL_CHOICE_VALUE)
Expand Down
10 changes: 5 additions & 5 deletions django_filters/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
]


class Filter(object):
class Filter:
creation_counter = 0
field_class = forms.Field

Expand Down Expand Up @@ -291,7 +291,7 @@ class DurationFilter(Filter):
field_class = forms.DurationField


class QuerySetRequestMixin(object):
class QuerySetRequestMixin:
"""
Add callable functionality to filters that support the ``queryset``
argument. If the ``queryset`` is callable, then it **must** accept the
Expand Down Expand Up @@ -642,10 +642,10 @@ def field(self):

def filter(self, qs, lookup):
if not lookup:
return super(LookupChoiceFilter, self).filter(qs, None)
return super().filter(qs, None)

self.lookup_expr = lookup.lookup_expr
return super(LookupChoiceFilter, self).filter(qs, lookup.value)
return super().filter(qs, lookup.value)


class OrderingFilter(BaseCSVFilter, ChoiceFilter):
Expand Down Expand Up @@ -746,7 +746,7 @@ def build_choices(self, fields, labels):
return [val for pair in zip(ascending, descending) for val in pair]


class FilterMethod(object):
class FilterMethod:
"""
This helper is used to override Filter.filter() when a 'method' argument
is passed. It proxies the call to the actual method on the filter's parent.
Expand Down
4 changes: 2 additions & 2 deletions django_filters/filterset.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def remote_queryset(field):
return model._default_manager.complex_filter(limit_choices_to)


class FilterSetOptions(object):
class FilterSetOptions:
def __init__(self, options=None):
self.model = getattr(options, 'model', None)
self.fields = getattr(options, 'fields', None)
Expand Down Expand Up @@ -184,7 +184,7 @@ def visit(name):
}


class BaseFilterSet(object):
class BaseFilterSet:
FILTER_DEFAULTS = FILTER_FOR_DBFIELD_DEFAULTS

def __init__(self, data=None, queryset=None, *, request=None, prefix=None):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_behavior(self):
def func():
pass

class Class(object):
class Class:
def __call__(self):
pass

Expand Down

0 comments on commit eca2c1f

Please sign in to comment.