From e63a13f87b328e9938e7459be3fd8b488226035d Mon Sep 17 00:00:00 2001 From: Dragon Date: Mon, 6 May 2024 16:37:30 +0100 Subject: [PATCH] Resolved flake8 errors (#503) --- setup.cfg | 6 ++++++ waffle/__init__.py | 1 - waffle/management/commands/waffle_flag.py | 4 ++-- waffle/managers.py | 2 +- waffle/models.py | 4 ++-- waffle/tests/test_models.py | 2 +- waffle/testutils.py | 1 - 7 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..6848cd9c --- /dev/null +++ b/setup.cfg @@ -0,0 +1,6 @@ +[flake8] +extend-ignore = + # break before binary operators + W503, + # line length + E501 diff --git a/waffle/__init__.py b/waffle/__init__.py index 5fd96c67..36cbd438 100755 --- a/waffle/__init__.py +++ b/waffle/__init__.py @@ -2,7 +2,6 @@ from typing import TYPE_CHECKING -import django from django.core.exceptions import ImproperlyConfigured from django.http import HttpRequest diff --git a/waffle/management/commands/waffle_flag.py b/waffle/management/commands/waffle_flag.py index 839cef27..052150bc 100644 --- a/waffle/management/commands/waffle_flag.py +++ b/waffle/management/commands/waffle_flag.py @@ -163,8 +163,8 @@ def handle(self, *args: Any, **options: Any) -> None: for username in options['user']: try: user_instance = UserModel.objects.get( - Q(**{UserModel.USERNAME_FIELD: username}) | - Q(**{UserModel.EMAIL_FIELD: username}) + Q(**{UserModel.USERNAME_FIELD: username}) + | Q(**{UserModel.EMAIL_FIELD: username}) ) user_hash.add(user_instance) except UserModel.DoesNotExist: diff --git a/waffle/managers.py b/waffle/managers.py index 4d8925f6..4f9216d3 100644 --- a/waffle/managers.py +++ b/waffle/managers.py @@ -6,7 +6,7 @@ if TYPE_CHECKING: - from waffle.models import _BaseModelType, AbstractBaseFlag, AbstractBaseSample, AbstractBaseSwitch + from waffle.models import _BaseModelType, AbstractBaseFlag, AbstractBaseSample, AbstractBaseSwitch # noqa: F401 else: _BaseModelType = TypeVar("_BaseModelType") diff --git a/waffle/models.py b/waffle/models.py index ffa58e7d..fa1c4a55 100644 --- a/waffle/models.py +++ b/waffle/models.py @@ -253,8 +253,8 @@ def _is_active_for_user(self, request: HttpRequest) -> bool | None: def _is_active_for_language(self, request: HttpRequest) -> bool | None: if self.languages: languages = [ln.strip() for ln in self.languages.split(',')] - if (hasattr(request, 'LANGUAGE_CODE') and - request.LANGUAGE_CODE in languages): + if (hasattr(request, 'LANGUAGE_CODE') + and request.LANGUAGE_CODE in languages): return True return None diff --git a/waffle/tests/test_models.py b/waffle/tests/test_models.py index 7ec9b4a7..fbe72c1f 100644 --- a/waffle/tests/test_models.py +++ b/waffle/tests/test_models.py @@ -35,4 +35,4 @@ def test_flag_is_not_active_for_none_requests(self): def test_is_active_for_user_when_everyone_is_active(self): flag = get_waffle_flag_model().objects.create(name='test-flag') flag.everyone = True - self.assertEqual(flag.is_active_for_user(User()), True) \ No newline at end of file + self.assertEqual(flag.is_active_for_user(User()), True) diff --git a/waffle/testutils.py b/waffle/testutils.py index c54b81cc..72e29674 100644 --- a/waffle/testutils.py +++ b/waffle/testutils.py @@ -7,7 +7,6 @@ get_waffle_sample_model, get_waffle_switch_model, ) -from waffle.models import Switch, Sample __all__ = ['override_flag', 'override_sample', 'override_switch']