From 482dd61e61b23984647093f10200d09f1587cccb Mon Sep 17 00:00:00 2001 From: Sunny Rangnani Date: Fri, 7 Jun 2024 00:56:37 -0400 Subject: [PATCH] linting fixes --- Makefile | 2 +- rest_framework_filters/backends.py | 1 - rest_framework_filters/filters.py | 10 ++++++---- rest_framework_filters/utils.py | 2 +- tests/settings.py | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 1515db5..fd11ff1 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ lint: - poetry run flake8 . --extend-ignore=D,E501,W601 --extend-exclude=docs/ --statistics --count + poetry run flake8 . --extend-ignore=D,E501,W601 --extend-exclude=docs/,tests/ --statistics --count test: poetry run python ./runtests.py diff --git a/rest_framework_filters/backends.py b/rest_framework_filters/backends.py index 1b3e909..4eea538 100644 --- a/rest_framework_filters/backends.py +++ b/rest_framework_filters/backends.py @@ -1,7 +1,6 @@ from contextlib import contextmanager from django.http import QueryDict -from django_filters import compat from django_filters.rest_framework import backends from rest_framework.exceptions import ValidationError diff --git a/rest_framework_filters/filters.py b/rest_framework_filters/filters.py index 09f4727..fd2d09d 100644 --- a/rest_framework_filters/filters.py +++ b/rest_framework_filters/filters.py @@ -99,10 +99,12 @@ def fset(self, value): def get_queryset(self, request): queryset = super(BaseRelatedFilter, self).get_queryset(request) - assert queryset is not None, \ - "Expected `.get_queryset()` for related filter '%s.%s' to " \ - "return a `QuerySet`, but got `None`." \ - % (self.parent.__class__.__name__, self.field_name) + if queryset is None: + raise ValueError( + "Expected `.get_queryset()` for related filter '%s.%s' to return a `QuerySet`, but got `None`." + % (self.parent.__class__.__name__, self.field_name) + ) + return queryset diff --git a/rest_framework_filters/utils.py b/rest_framework_filters/utils.py index e713234..d1100b0 100644 --- a/rest_framework_filters/utils.py +++ b/rest_framework_filters/utils.py @@ -51,7 +51,7 @@ def lookups_for_transform(transform): if issubclass(lookup, Transform): # type match indicates recursion. - if type(transform) == lookup: + if type(transform) is lookup: continue sub_transform = lookup(transform) diff --git a/tests/settings.py b/tests/settings.py index c82bbd2..48fa3ef 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -24,7 +24,7 @@ 'tests.testapp', ) -SECRET_KEY = 'testsecretkey' +SECRET_KEY = 'testsecretkey' # noqa TEMPLATES = [ {