diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 013e2e5547..bafeca8957 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -54,6 +54,38 @@ jobs: run: | black --check --diff src + flake8: + name: Code style (flake8) + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up backend environment + uses: maykinmedia/setup-django-backend@v1 + with: + apt-packages: 'libxml2-dev libxmlsec1-dev libxmlsec1-openssl gdal-bin' + python-version: '3.11' + setup-node: 'no' + - name: Run flake8 + id: flake8 + run: | + flake8 src 2>&1 | tee flake8_output.txt + result_code=${PIPESTATUS[0]} + report="$(cat flake8_output.txt)" + report="${report//$'\n'/'%0A'}" # escape newlines + echo "flake8_output=${report}" >> $GITHUB_OUTPUT + exit $result_code + - name: Emit flake8 flake8 output + if: ${{ failure() }} + run: | + echo "${{ steps.flake8.outputs.flake8_output }}" + + echo 'flake8 found some issues' >> $GITHUB_STEP_SUMMARY + echo '' >> $GITHUB_STEP_SUMMARY + echo '| File | Line | Column | Issue |' >> $GITHUB_STEP_SUMMARY + echo '| :--- | ---- | ------ | :---- |' >> $GITHUB_STEP_SUMMARY + python ./bin/flake8_summary.py "${{ steps.flake8.outputs.flake8_output }}" >> $GITHUB_STEP_SUMMARY + migrations: name: Check for model changes not present in the migrations runs-on: ubuntu-latest diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 99aceacd45..e215f40def 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,17 +4,17 @@ If you want to contribute, we ask you to follow these guidelines. ## Reporting bugs -If you have encountered a bug in this project, please check if an issue already -exists in the list of existing [issues][issues]. If such an issue does not -exist, you can create a [new issue][new_issue]. When writing the bug report, +If you have encountered a bug in this project, please check if an issue already +exists in the list of existing [issues][issues]. If such an issue does not +exist, you can create a [new issue][new_issue]. When writing the bug report, try to add a clear example that shows how to reproduce said bug. ## Adding new features -Before making making changes to the code, we advise you to first check the list -of existing [issues][issues] for this project to see if an issue for the -suggested changes already exists. If such an issue does not exist, you can -create a [new issue][new_issue]. Creating an issue gives an opportunity for +Before making making changes to the code, we advise you to first check the list +of existing [issues][issues] for this project to see if an issue for the +suggested changes already exists. If such an issue does not exist, you can +create a [new issue][new_issue]. Creating an issue gives an opportunity for other developers to give tips even before you start coding. ### Code style @@ -22,21 +22,22 @@ other developers to give tips even before you start coding. To keep the code clean and readable, this project uses: - [`isort`](https://github.com/timothycrosley/isort) to order the imports -- [`black`](https://github.com/psf/black) to format the Python code and keep diffs for +- [`black`](https://github.com/psf/black) to format the Python code and keep diffs for pull requests small -- [`prettier`](https://github.com/prettier/prettier) to format the JS code and keep diffs for +- [`flake8`](https://github.com/PyCQA/flake8) to clean up code (removing unused imports, etc.) +- [`prettier`](https://github.com/prettier/prettier) to format the JS code and keep diffs for pull requests small -Whenever a branch is pushed or a pull request is made, the code will be checked -in CI by the tools mentioned above, so make sure to install these tools and run +Whenever a branch is pushed or a pull request is made, the code will be checked +in CI by the tools mentioned above, so make sure to install these tools and run them locally before pushing branches/making pull requests. -This project aims to meet the criteria of the -[Standard for Public Code][Standard_for_Public_Code]. Please make sure that +This project aims to meet the criteria of the +[Standard for Public Code][Standard_for_Public_Code]. Please make sure that your pull requests are compliant, that will make the reviews quicker. ### Forking the repository -In order to implement changes to this project when you do not have rights for +In order to implement changes to this project when you do not have rights for this [repository][repository], you must first fork the repository. Once the repository is forked, you can clone it to your local machine. @@ -46,26 +47,26 @@ On your local machine, create a new branch, and name it like: - `feature/some-new-feature`, if the changes implement a new feature - `issue/some-issue`, if the changes fix an issue -Once you have made changes or additions to the code, you can commit them (try -to keep the commit message descriptive but short). If an issue already exists -in the list of existing [issues][issues] for the changes you made, be sure to -format your commit message like -`:gitmoji: Fixes # -- description of changes made`, where -`` corresponds to the number of the issue on GitHub. To demonstrate -that the changes implement the new feature/fix the issue, make sure to also add +Once you have made changes or additions to the code, you can commit them (try +to keep the commit message descriptive but short). If an issue already exists +in the list of existing [issues][issues] for the changes you made, be sure to +format your commit message like +`:gitmoji: Fixes # -- description of changes made`, where +`` corresponds to the number of the issue on GitHub. To demonstrate +that the changes implement the new feature/fix the issue, make sure to also add tests to the existing Django testsuite. ### Making a pull request -If all changes have been committed, you can push the branch to your fork of the -repository and create a pull request to the `develop` branch of this project's -repository. Your pull request will be reviewed, if applicable, feedback will be +If all changes have been committed, you can push the branch to your fork of the +repository and create a pull request to the `develop` branch of this project's +repository. Your pull request will be reviewed, if applicable, feedback will be given and if everything is approved, it will be merged. ### Reviews on releases -All pull requests will be reviewed by a project member before they are merged -to a release branch. +All pull requests will be reviewed by a project member before they are merged +to a release branch. [issues]: https://github.com/maykinmedia/open-inwoner/issues diff --git a/bin/flake8_summary.py b/bin/flake8_summary.py new file mode 100644 index 0000000000..7a05d5df42 --- /dev/null +++ b/bin/flake8_summary.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python +import sys + + +def main(flake8_output: str): + for line in flake8_output.splitlines(): + file, line, column, error = line.split(":", 3) + print(f"| {file} | {line} | {column} | {error.strip()} |") + + +if __name__ == "__main__": + main(sys.argv[1]) diff --git a/requirements/ci.txt b/requirements/ci.txt index 20c328fe1d..32fac297e2 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -41,6 +41,8 @@ billiard==3.6.4.0 # -c requirements/base.txt # -r requirements/base.txt # celery +black==22.12.0 + # via -r requirements/test-tools.in boltons==21.0.0 # via # -c requirements/base.txt @@ -81,6 +83,7 @@ click==8.1.3 # via # -c requirements/base.txt # -r requirements/base.txt + # black # celery # click-didyoumean # click-plugins @@ -499,6 +502,8 @@ factory-boy==3.2.0 # via -r requirements/test-tools.in faker==9.9.0 # via factory-boy +flake8==3.9.2 + # via -r requirements/test-tools.in fontawesomefree==6.4.2 # via # -c requirements/base.txt @@ -568,7 +573,9 @@ isodate==0.6.1 # -r requirements/base.txt # maykin-python3-saml isort==5.9.3 - # via pylint + # via + # -r requirements/test-tools.in + # pylint josepy==1.13.0 # via # -c requirements/base.txt @@ -628,7 +635,9 @@ maykin-python3-saml==1.14.0.post0 # -r requirements/base.txt # django-digid-eherkenning mccabe==0.6.1 - # via pylint + # via + # flake8 + # pylint messagebird==2.1.0 # via # -c requirements/base.txt @@ -642,6 +651,8 @@ mozilla-django-oidc-db==0.12.0 # via # -c requirements/base.txt # -r requirements/base.txt +mypy-extensions==1.0.0 + # via black notifications-api-common==0.2.2 # via # -c requirements/base.txt @@ -670,6 +681,8 @@ packaging==23.0 # -c requirements/base.txt # -r requirements/base.txt # djangocms-text-ckeditor +pathspec==0.12.1 + # via black pep8==1.7.1 # via -r requirements/test-tools.in phonenumbers==8.12.33 @@ -685,7 +698,9 @@ pillow==10.1.0 # reportlab # weasyprint platformdirs==2.4.0 - # via pylint + # via + # black + # pylint playwright==1.41.0 # via # -c requirements/base.txt @@ -704,6 +719,8 @@ psycopg2==2.9.9 # via # -c requirements/base.txt # -r requirements/base.txt +pycodestyle==2.7.0 + # via flake8 pycparser==2.20 # via # -c requirements/base.txt @@ -719,6 +736,8 @@ pyee==11.0.1 # -c requirements/base.txt # -r requirements/base.txt # playwright +pyflakes==2.3.1 + # via flake8 pyjwt==2.8.0 # via # -c requirements/base.txt diff --git a/requirements/dev.in b/requirements/dev.in index 9b141a3f8b..0961cc18db 100644 --- a/requirements/dev.in +++ b/requirements/dev.in @@ -4,9 +4,6 @@ pip-tools # Code formatting -black -isort -flake8 bandit # Debug tooling diff --git a/requirements/dev.txt b/requirements/dev.txt index 405252cce3..0fdefc1ac5 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -53,7 +53,9 @@ billiard==3.6.4.0 # -r requirements/ci.txt # celery black==22.12.0 - # via -r requirements/dev.in + # via + # -c requirements/ci.txt + # -r requirements/ci.txt blinker==1.7.0 # via flask boltons==21.0.0 @@ -555,7 +557,9 @@ faker==9.9.0 # -r requirements/ci.txt # factory-boy flake8==3.9.2 - # via -r requirements/dev.in + # via + # -c requirements/ci.txt + # -r requirements/ci.txt flask==3.0.0 # via # flask-basicauth @@ -654,7 +658,6 @@ isort==5.9.3 # via # -c requirements/ci.txt # -r requirements/ci.txt - # -r requirements/dev.in # pylint itsdangerous==2.1.2 # via flask @@ -750,8 +753,11 @@ mozilla-django-oidc-db==0.12.0 # -r requirements/ci.txt msgpack==1.0.7 # via locust -mypy-extensions==0.4.3 - # via black +mypy-extensions==1.0.0 + # via + # -c requirements/ci.txt + # -r requirements/ci.txt + # black notifications-api-common==0.2.2 # via # -c requirements/ci.txt @@ -782,8 +788,11 @@ packaging==23.0 # build # djangocms-text-ckeditor # sphinx -pathspec==0.9.0 - # via black +pathspec==0.12.1 + # via + # -c requirements/ci.txt + # -r requirements/ci.txt + # black pbr==5.9.0 # via stevedore pep517==0.11.0 @@ -834,6 +843,8 @@ psycopg2==2.9.9 # -r requirements/ci.txt pycodestyle==2.7.0 # via + # -c requirements/ci.txt + # -r requirements/ci.txt # autopep8 # flake8 pycparser==2.20 @@ -852,7 +863,10 @@ pyee==11.0.1 # -r requirements/ci.txt # playwright pyflakes==2.3.1 - # via flake8 + # via + # -c requirements/ci.txt + # -r requirements/ci.txt + # flake8 pygments==2.12.0 # via sphinx pyjwt==2.8.0 diff --git a/requirements/test-tools.in b/requirements/test-tools.in index b208bd2b9a..decbda49a3 100644 --- a/requirements/test-tools.in +++ b/requirements/test-tools.in @@ -11,5 +11,10 @@ pyquery # integrates with webtest requests-mock tblib +# Code formatting +black +isort +flake8 + # DigidLocal pyopenssl diff --git a/requirements/test-tools.txt b/requirements/test-tools.txt deleted file mode 100644 index 4f554446d7..0000000000 --- a/requirements/test-tools.txt +++ /dev/null @@ -1,104 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.11 -# by the following command: -# -# pip-compile requirements/test-tools.in -# -astroid==3.0.2 - # via pylint -beautifulsoup4==4.10.0 - # via - # -c requirements/base.txt - # webtest -certifi==2023.11.17 - # via - # -c requirements/base.txt - # requests -cffi==1.15.0 - # via - # -c requirements/base.txt - # cryptography -charset-normalizer==2.0.6 - # via - # -c requirements/base.txt - # requests -coverage==4.5.4 - # via -r requirements/test-tools.in -cryptography==41.0.7 - # via - # -c requirements/base.txt - # pyopenssl -cssselect==1.2.0 - # via pyquery -dill==0.3.7 - # via pylint -django-webtest==1.9.11 - # via -r requirements/test-tools.in -factory-boy==3.3.0 - # via -r requirements/test-tools.in -faker==22.5.0 - # via factory-boy -freezegun==1.4.0 - # via -r requirements/test-tools.in -idna==3.2 - # via - # -c requirements/base.txt - # requests -isort==5.13.2 - # via pylint -lxml==4.9.1 - # via - # -c requirements/base.txt - # pyquery -mccabe==0.7.0 - # via pylint -pep8==1.7.1 - # via -r requirements/test-tools.in -platformdirs==4.1.0 - # via pylint -pycparser==2.20 - # via - # -c requirements/base.txt - # cffi -pylint==3.0.3 - # via -r requirements/test-tools.in -pyopenssl==23.3.0 - # via - # -c requirements/base.txt - # -r requirements/test-tools.in -pyquery==2.0.0 - # via -r requirements/test-tools.in -python-dateutil==2.8.2 - # via - # -c requirements/base.txt - # faker - # freezegun -requests==2.31.0 - # via - # -c requirements/base.txt - # requests-mock -requests-mock==1.11.0 - # via -r requirements/test-tools.in -six==1.16.0 - # via - # -c requirements/base.txt - # python-dateutil - # requests-mock -soupsieve==2.3.1 - # via - # -c requirements/base.txt - # beautifulsoup4 -tblib==3.0.0 - # via -r requirements/test-tools.in -tomlkit==0.12.3 - # via pylint -urllib3==1.26.18 - # via - # -c requirements/base.txt - # requests -waitress==2.1.2 - # via webtest -webob==1.8.7 - # via webtest -webtest==3.0.0 - # via django-webtest diff --git a/setup.cfg b/setup.cfg index c1b35519ad..279fe7c9f2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,6 +3,17 @@ ignore=W293,W291,E501,E261 max-line-length=88 exclude=migrations,static,media +[flake8] +ignore=E203,E261,E501,E731,F405,W293,W291,W503,F841,E741 +max-line-length=88 +exclude= + migrations + static + media + node_modules + src/open_inwoner/conf/local_example.py + # Might be created by developers: + src/open_inwoner/conf/local.py [isort] combine_as_imports = true diff --git a/src/digid_eherkenning_oidc_generics/forms.py b/src/digid_eherkenning_oidc_generics/forms.py index 27aec6e208..34a64ad445 100644 --- a/src/digid_eherkenning_oidc_generics/forms.py +++ b/src/digid_eherkenning_oidc_generics/forms.py @@ -1,7 +1,5 @@ from copy import deepcopy -from django.utils.translation import gettext_lazy as _ - from mozilla_django_oidc_db.constants import OIDC_MAPPING as _OIDC_MAPPING from mozilla_django_oidc_db.forms import OpenIDConnectConfigForm diff --git a/src/digid_eherkenning_oidc_generics/views.py b/src/digid_eherkenning_oidc_generics/views.py index 70633cad83..d9b32dbe2b 100644 --- a/src/digid_eherkenning_oidc_generics/views.py +++ b/src/digid_eherkenning_oidc_generics/views.py @@ -2,13 +2,10 @@ from django.conf import settings from django.contrib import auth, messages -from django.core.exceptions import ValidationError -from django.db import IntegrityError, transaction from django.http import HttpResponseRedirect from django.shortcuts import resolve_url from django.urls import reverse, reverse_lazy from django.utils.translation import gettext_lazy as _ -from django.views import View from django.views.generic import View import requests @@ -19,7 +16,6 @@ from mozilla_django_oidc_db.views import ( OIDC_ERROR_SESSION_KEY, OIDCCallbackView as _OIDCCallbackView, - get_exception_message, ) from digid_eherkenning_oidc_generics.mixins import ( diff --git a/src/eherkenning/tests/test_mock_forms.py b/src/eherkenning/tests/test_mock_forms.py index aa52ebf327..a70c55f639 100644 --- a/src/eherkenning/tests/test_mock_forms.py +++ b/src/eherkenning/tests/test_mock_forms.py @@ -1,4 +1,4 @@ -from django.test import TestCase, modify_settings, override_settings +from django.test import TestCase from eherkenning.mock.idp.forms import eHerkenningPasswordLoginForm diff --git a/src/open_inwoner/accounts/admin.py b/src/open_inwoner/accounts/admin.py index 4a2af3f162..ebecd86293 100644 --- a/src/open_inwoner/accounts/admin.py +++ b/src/open_inwoner/accounts/admin.py @@ -3,9 +3,8 @@ from django.contrib.auth.forms import UserChangeForm, UserCreationForm from django.contrib.auth.models import Group from django.forms import ValidationError -from django.http.request import HttpRequest -from django.urls import reverse, reverse_lazy -from django.utils.html import format_html, format_html_join +from django.urls import reverse +from django.utils.html import format_html from django.utils.translation import ngettext, ugettext_lazy as _ from image_cropping import ImageCroppingMixin diff --git a/src/open_inwoner/accounts/apps.py b/src/open_inwoner/accounts/apps.py index 2c3e95a722..a92fac11c3 100644 --- a/src/open_inwoner/accounts/apps.py +++ b/src/open_inwoner/accounts/apps.py @@ -25,7 +25,7 @@ def update_admin_index(sender, **kwargs): try: call_command("loaddata", "django-admin-index", verbosity=0, stdout=StringIO()) - except: + except: # noqa print("Error: Unable to load django-admin-index fixture!") print("Loaded django-admin-index fixture") @@ -34,6 +34,9 @@ class AccountsConfig(AppConfig): name = "open_inwoner.accounts" def ready(self): - from .signals import log_user_login, log_user_logout # register the signals + from .signals import ( # noqa:register the signals + log_user_login, + log_user_logout, + ) post_migrate.connect(update_admin_index, sender=self) diff --git a/src/open_inwoner/accounts/models.py b/src/open_inwoner/accounts/models.py index b07c5da1f2..9781833106 100644 --- a/src/open_inwoner/accounts/models.py +++ b/src/open_inwoner/accounts/models.py @@ -1,9 +1,9 @@ import os -from datetime import date, timedelta +from datetime import timedelta from uuid import uuid4 from django.conf import settings -from django.contrib.auth.models import AbstractBaseUser, Group, PermissionsMixin +from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin from django.contrib.contenttypes.fields import GenericRelation from django.core.exceptions import ValidationError from django.db import models diff --git a/src/open_inwoner/accounts/query.py b/src/open_inwoner/accounts/query.py index 0a88444bb8..454d307edf 100644 --- a/src/open_inwoner/accounts/query.py +++ b/src/open_inwoner/accounts/query.py @@ -1,6 +1,11 @@ -from django.db.models import Case, F, Max, OuterRef, Q, Subquery, Value, When +from typing import TYPE_CHECKING + +from django.db.models import Case, F, Max, OuterRef, Q, Subquery, When from django.db.models.query import QuerySet +if TYPE_CHECKING: + from open_inwoner.accounts.models import User + class MessageQuerySet(QuerySet): def get_conversations_for_user(self, user: "User") -> "MessageQuerySet": diff --git a/src/open_inwoner/accounts/signals.py b/src/open_inwoner/accounts/signals.py index bfd3090089..bf55a7405d 100644 --- a/src/open_inwoner/accounts/signals.py +++ b/src/open_inwoner/accounts/signals.py @@ -1,4 +1,3 @@ -from django.conf import settings from django.contrib.auth.signals import user_logged_in, user_logged_out from django.dispatch import receiver from django.urls import reverse @@ -27,7 +26,7 @@ def log_user_login(sender, user, request, *args, **kwargs): try: digid_path = reverse("digid:acs") - except: + except: # noqa digid_path = "" if current_path == reverse("admin:login"): diff --git a/src/open_inwoner/accounts/tests/factories.py b/src/open_inwoner/accounts/tests/factories.py index 710e908f27..18b6407ded 100644 --- a/src/open_inwoner/accounts/tests/factories.py +++ b/src/open_inwoner/accounts/tests/factories.py @@ -1,5 +1,4 @@ import random -from datetime import datetime, timezone from uuid import uuid4 from django.core.files.uploadedfile import SimpleUploadedFile diff --git a/src/open_inwoner/accounts/tests/test_action_views.py b/src/open_inwoner/accounts/tests/test_action_views.py index a5688ab89b..c6fb613079 100644 --- a/src/open_inwoner/accounts/tests/test_action_views.py +++ b/src/open_inwoner/accounts/tests/test_action_views.py @@ -207,7 +207,7 @@ def test_action_list_export(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.content_type, "application/pdf") self.assertEqual( - response["Content-Disposition"], f'attachment; filename="actions.pdf"' + response["Content-Disposition"], 'attachment; filename="actions.pdf"' ) self.assertEqual(list(response.context["actions"]), [self.action]) diff --git a/src/open_inwoner/accounts/tests/test_auth.py b/src/open_inwoner/accounts/tests/test_auth.py index c1636d2e28..f2c2898cae 100644 --- a/src/open_inwoner/accounts/tests/test_auth.py +++ b/src/open_inwoner/accounts/tests/test_auth.py @@ -1,10 +1,9 @@ -from datetime import date from unittest.mock import patch from urllib.parse import urlencode from django.contrib.sites.models import Site from django.core import mail -from django.test import modify_settings, override_settings +from django.test import override_settings from django.urls import reverse, reverse_lazy from django.utils.translation import gettext as _ @@ -20,7 +19,6 @@ from open_inwoner.configurations.models import SiteConfiguration from open_inwoner.haalcentraal.tests.mixins import HaalCentraalMixin from open_inwoner.kvk.branches import get_kvk_branch_number -from open_inwoner.kvk.models import KvKConfig from open_inwoner.kvk.tests.factories import CertificateFactory from ...cms.tests import cms_tools diff --git a/src/open_inwoner/accounts/tests/test_oidc_views.py b/src/open_inwoner/accounts/tests/test_oidc_views.py index 9640722f35..fb5346087d 100644 --- a/src/open_inwoner/accounts/tests/test_oidc_views.py +++ b/src/open_inwoner/accounts/tests/test_oidc_views.py @@ -5,7 +5,6 @@ from django.core.exceptions import ValidationError from django.test import TestCase, modify_settings, override_settings from django.urls import reverse -from django.utils.translation import gettext as _ import requests_mock from furl import furl diff --git a/src/open_inwoner/accounts/tests/test_profile_views.py b/src/open_inwoner/accounts/tests/test_profile_views.py index 0beb05513c..d643e41eb4 100644 --- a/src/open_inwoner/accounts/tests/test_profile_views.py +++ b/src/open_inwoner/accounts/tests/test_profile_views.py @@ -12,7 +12,6 @@ from cms import api from django_webtest import WebTest from pyquery import PyQuery as PQ -from timeline_logger.models import TimelineLog from webtest import Upload from open_inwoner.accounts.choices import StatusChoices @@ -35,7 +34,6 @@ from .factories import ( ActionFactory, DigidUserFactory, - DocumentFactory, UserFactory, eHerkenningUserFactory, ) diff --git a/src/open_inwoner/accounts/tests/test_user.py b/src/open_inwoner/accounts/tests/test_user.py index 38b4574af2..50e777ef6a 100644 --- a/src/open_inwoner/accounts/tests/test_user.py +++ b/src/open_inwoner/accounts/tests/test_user.py @@ -1,9 +1,5 @@ -from datetime import date - from django.test import TestCase -from freezegun import freeze_time - from open_inwoner.accounts.choices import LoginTypeChoices from open_inwoner.utils.hash import generate_email_from_string diff --git a/src/open_inwoner/accounts/views/__init__.py b/src/open_inwoner/accounts/views/__init__.py index 46324f7094..1174dbcd8d 100644 --- a/src/open_inwoner/accounts/views/__init__.py +++ b/src/open_inwoner/accounts/views/__init__.py @@ -36,3 +36,40 @@ from .password_reset import PasswordResetView from .profile import EditProfileView, MyDataView, MyNotificationsView, MyProfileView from .registration import CustomRegistrationView, NecessaryFieldsUserView + +__all__ = [ + "ActionCreateView", + "ActionExportView", + "ActionHistoryView", + "ActionListExportView", + "ActionListView", + "ActionPrivateMediaView", + "ActionUpdateStatusTagView", + "ActionUpdateView", + "CustomDigiDAssertionConsumerServiceMockView", + "CustomDigiDAssertionConsumerServiceView", + "CustomeHerkenningAssertionConsumerServiceMockView", + "CustomeHerkenningAssertionConsumerServiceView", + "LogPasswordChangeView", + "LogPasswordResetConfirmView", + "LogPasswordResetView", + "ContactApprovalView", + "ContactCreateView", + "ContactDeleteView", + "ContactListView", + "csrf_failure", + "DocumentPrivateMediaView", + "DocumentDeleteView", + "InviteAcceptView", + "AddPhoneNumberWizardView", + "CustomLoginView", + "ResendTokenView", + "VerifyTokenView", + "PasswordResetView", + "EditProfileView", + "MyDataView", + "MyNotificationsView", + "MyProfileView", + "CustomRegistrationView", + "NecessaryFieldsUserView", +] diff --git a/src/open_inwoner/accounts/views/login.py b/src/open_inwoner/accounts/views/login.py index 8070afc54c..2ad38c5453 100644 --- a/src/open_inwoner/accounts/views/login.py +++ b/src/open_inwoner/accounts/views/login.py @@ -17,10 +17,6 @@ from furl import furl from oath import totp -from digid_eherkenning_oidc_generics.models import ( - OpenIDConnectDigiDConfig, - OpenIDConnectEHerkenningConfig, -) from open_inwoner.configurations.models import SiteConfiguration from open_inwoner.utils.mixins import ThrottleMixin from open_inwoner.utils.views import LogMixin diff --git a/src/open_inwoner/accounts/views/profile.py b/src/open_inwoner/accounts/views/profile.py index 1980feee5b..e9232a0a6a 100644 --- a/src/open_inwoner/accounts/views/profile.py +++ b/src/open_inwoner/accounts/views/profile.py @@ -1,20 +1,17 @@ -from datetime import date, datetime +from datetime import date from typing import Generator, Union -from django.conf import settings from django.contrib import messages from django.contrib.auth.mixins import LoginRequiredMixin -from django.db.models import Q from django.forms.forms import Form from django.http import HttpResponseRedirect from django.shortcuts import redirect from django.urls import reverse, reverse_lazy from django.utils.functional import cached_property from django.utils.translation import gettext as _ -from django.views.generic import DetailView, FormView, TemplateView, UpdateView +from django.views.generic import FormView, TemplateView, UpdateView from aldryn_apphooks_config.mixins import AppConfigMixin -from glom import glom from view_breadcrumbs import BaseBreadcrumbMixin from open_inwoner.accounts.choices import ( @@ -31,7 +28,6 @@ from open_inwoner.openklant.wrap import get_fetch_parameters from open_inwoner.plans.models import Plan from open_inwoner.questionnaire.models import QuestionnaireStep -from open_inwoner.utils.mixins import ExportMixin from open_inwoner.utils.views import CommonPageMixin, LogMixin from ..forms import BrpUserForm, UserForm, UserNotificationsForm diff --git a/src/open_inwoner/accounts/views/registration.py b/src/open_inwoner/accounts/views/registration.py index 3368d2a96c..74f84a751e 100644 --- a/src/open_inwoner/accounts/views/registration.py +++ b/src/open_inwoner/accounts/views/registration.py @@ -58,7 +58,7 @@ def add_invitee(self, invite, user): # update inviter - invitee relationship inviter_contacts = invite.inviter.user_contacts.all() invitee = invite.invitee - if not invitee in inviter_contacts: + if invitee not in inviter_contacts: invite.inviter.user_contacts.add(invitee) diff --git a/src/open_inwoner/api/tests/test_views.py b/src/open_inwoner/api/tests/test_views.py index 6ef456985f..a3e504fcdb 100644 --- a/src/open_inwoner/api/tests/test_views.py +++ b/src/open_inwoner/api/tests/test_views.py @@ -1,5 +1,3 @@ -from unicodedata import category - from django.urls import reverse from rest_framework import status diff --git a/src/open_inwoner/apimock/tests/test_views.py b/src/open_inwoner/apimock/tests/test_views.py index ccb69d8d1c..a1ef5967f6 100644 --- a/src/open_inwoner/apimock/tests/test_views.py +++ b/src/open_inwoner/apimock/tests/test_views.py @@ -1,8 +1,6 @@ from django.test import TestCase from django.urls import reverse -from open_inwoner.accounts.tests.factories import UserFactory - class APIMockTest(TestCase): def test_basic_response(self): diff --git a/src/open_inwoner/cms/cases/tests/test_contactform.py b/src/open_inwoner/cms/cases/tests/test_contactform.py index 1e8421128c..a97a37b372 100644 --- a/src/open_inwoner/cms/cases/tests/test_contactform.py +++ b/src/open_inwoner/cms/cases/tests/test_contactform.py @@ -12,7 +12,6 @@ VertrouwelijkheidsAanduidingen, ) from zgw_consumers.constants import APITypes -from zgw_consumers.test import generate_oas_component from open_inwoner.accounts.tests.factories import ( DigidUserFactory, @@ -20,11 +19,7 @@ ) from open_inwoner.openklant.constants import Status from open_inwoner.openklant.models import OpenKlantConfig -from open_inwoner.openklant.tests.data import ( - CONTACTMOMENTEN_ROOT, - KLANTEN_ROOT, - MockAPIData, -) +from open_inwoner.openklant.tests.data import CONTACTMOMENTEN_ROOT, KLANTEN_ROOT from open_inwoner.openzaak.models import CatalogusConfig, OpenZaakConfig from open_inwoner.openzaak.tests.factories import ServiceFactory, ZaakTypeConfigFactory from open_inwoner.openzaak.tests.helpers import generate_oas_component_cached diff --git a/src/open_inwoner/cms/cases/tests/test_htmx.py b/src/open_inwoner/cms/cases/tests/test_htmx.py index 7ca122e555..a2880accab 100644 --- a/src/open_inwoner/cms/cases/tests/test_htmx.py +++ b/src/open_inwoner/cms/cases/tests/test_htmx.py @@ -18,11 +18,7 @@ from open_inwoner.configurations.models import SiteConfiguration from open_inwoner.openklant.constants import Status from open_inwoner.openklant.models import OpenKlantConfig -from open_inwoner.openklant.tests.data import ( - CONTACTMOMENTEN_ROOT, - KLANTEN_ROOT, - MockAPIData, -) +from open_inwoner.openklant.tests.data import CONTACTMOMENTEN_ROOT, KLANTEN_ROOT from open_inwoner.openzaak.models import OpenZaakConfig from open_inwoner.openzaak.tests.factories import ( ServiceFactory, diff --git a/src/open_inwoner/cms/cases/views/__init__.py b/src/open_inwoner/cms/cases/views/__init__.py index 7afdddfb80..29832011c4 100644 --- a/src/open_inwoner/cms/cases/views/__init__.py +++ b/src/open_inwoner/cms/cases/views/__init__.py @@ -6,3 +6,13 @@ InnerCaseDetailView, OuterCaseDetailView, ) + +__all__ = [ + "InnerCaseListView", + "OuterCaseListView", + "CaseContactFormView", + "CaseDocumentDownloadView", + "CaseDocumentUploadFormView", + "InnerCaseDetailView", + "OuterCaseDetailView", +] diff --git a/src/open_inwoner/cms/plugins/cms_plugins/__init__.py b/src/open_inwoner/cms/plugins/cms_plugins/__init__.py index c0440f6a04..ff68bb59e0 100644 --- a/src/open_inwoner/cms/plugins/cms_plugins/__init__.py +++ b/src/open_inwoner/cms/plugins/cms_plugins/__init__.py @@ -1,2 +1,7 @@ from .userfeed import UserFeedPlugin from .videoplayer import VideoPlayerPlugin + +__all__ = [ + "UserFeedPlugin", + "VideoPlayerPlugin", +] diff --git a/src/open_inwoner/cms/plugins/models/__init__.py b/src/open_inwoner/cms/plugins/models/__init__.py index dfb2044a9e..71f41ff6d5 100644 --- a/src/open_inwoner/cms/plugins/models/__init__.py +++ b/src/open_inwoner/cms/plugins/models/__init__.py @@ -1,2 +1,7 @@ from .userfeed import UserFeed from .videoplayer import VideoPlayer + +__all__ = [ + "UserFeed", + "VideoPlayer", +] diff --git a/src/open_inwoner/cms/plugins/tests/test_userfeed.py b/src/open_inwoner/cms/plugins/tests/test_userfeed.py index 44d75e0ae2..c38d6c704b 100644 --- a/src/open_inwoner/cms/plugins/tests/test_userfeed.py +++ b/src/open_inwoner/cms/plugins/tests/test_userfeed.py @@ -1,6 +1,6 @@ from django.test import TestCase from django.utils.html import strip_tags -from django.utils.translation import ngettext, ugettext as _ +from django.utils.translation import ngettext from pyquery import PyQuery as PQ diff --git a/src/open_inwoner/cms/products/urls.py b/src/open_inwoner/cms/products/urls.py index dc6ed8f4f9..f2991b7c75 100644 --- a/src/open_inwoner/cms/products/urls.py +++ b/src/open_inwoner/cms/products/urls.py @@ -41,23 +41,23 @@ name="location_detail", ), path( - f"producten//formulier/", + "producten//formulier/", ProductFormView.as_view(), name="product_form", ), path( # Required to handle dynamic URL-paths appended by Open Forms. - f"producten//formulier/", + "producten//formulier/", ProductFormView.as_view(), name="product_form", ), path( - f"producten//", + "producten//", ProductDetailView.as_view(), name="product_detail", ), path( - f"producten/", + "producten/", RedirectView.as_view(pattern_name="products:category_list"), name="product_detail", ), diff --git a/src/open_inwoner/cms/utils/plugin_mixins.py b/src/open_inwoner/cms/utils/plugin_mixins.py index 608e1a524b..e8fe225e17 100644 --- a/src/open_inwoner/cms/utils/plugin_mixins.py +++ b/src/open_inwoner/cms/utils/plugin_mixins.py @@ -1,5 +1,4 @@ from cms.models import Page -from cms.plugin_base import CMSPluginBase class CMSActiveAppMixin: diff --git a/src/open_inwoner/components/templatetags/anchor_menu_tags.py b/src/open_inwoner/components/templatetags/anchor_menu_tags.py index b8edc59415..37bf0dd282 100644 --- a/src/open_inwoner/components/templatetags/anchor_menu_tags.py +++ b/src/open_inwoner/components/templatetags/anchor_menu_tags.py @@ -1,5 +1,4 @@ from django import template -from django.urls import reverse from open_inwoner.components.utils import ComponentNode diff --git a/src/open_inwoner/components/templatetags/dropdown_tags.py b/src/open_inwoner/components/templatetags/dropdown_tags.py index 38423f27d1..e6e3835a75 100644 --- a/src/open_inwoner/components/templatetags/dropdown_tags.py +++ b/src/open_inwoner/components/templatetags/dropdown_tags.py @@ -1,5 +1,4 @@ from django import template -from django.urls import NoReverseMatch, reverse from open_inwoner.components.utils import ContentsNode, parse_component_with_args diff --git a/src/open_inwoner/components/templatetags/notification_tags.py b/src/open_inwoner/components/templatetags/notification_tags.py index 3c0710e025..18bf8e10f2 100644 --- a/src/open_inwoner/components/templatetags/notification_tags.py +++ b/src/open_inwoner/components/templatetags/notification_tags.py @@ -1,7 +1,5 @@ from django import template -from open_inwoner.components.utils import ContentsNode, parse_component_with_args - register = template.Library() diff --git a/src/open_inwoner/components/templatetags/questionnaire_tags.py b/src/open_inwoner/components/templatetags/questionnaire_tags.py index a3b8e22aa1..a948b04979 100644 --- a/src/open_inwoner/components/templatetags/questionnaire_tags.py +++ b/src/open_inwoner/components/templatetags/questionnaire_tags.py @@ -1,6 +1,5 @@ from django import template from django.db.models import QuerySet -from django.utils.translation import gettext as _ register = template.Library() diff --git a/src/open_inwoner/components/tests/test_header.py b/src/open_inwoner/components/tests/test_header.py index eedfa69b05..ab00dbe81e 100644 --- a/src/open_inwoner/components/tests/test_header.py +++ b/src/open_inwoner/components/tests/test_header.py @@ -1,4 +1,4 @@ -from django.test import TestCase, modify_settings +from django.test import TestCase from pyquery import PyQuery diff --git a/src/open_inwoner/conf/base.py b/src/open_inwoner/conf/base.py index d5a79594ca..f4734b4e11 100644 --- a/src/open_inwoner/conf/base.py +++ b/src/open_inwoner/conf/base.py @@ -1,9 +1,9 @@ import os -from django.urls import reverse_lazy from django.utils.translation import ugettext_lazy as _ import sentry_sdk +from easy_thumbnails.conf import Settings as thumbnail_settings from log_outgoing_requests.formatters import HttpFormatter from .utils import config, get_sentry_integrations @@ -671,7 +671,6 @@ }, } -from easy_thumbnails.conf import Settings as thumbnail_settings THUMBNAIL_PROCESSORS = ( "filer.thumbnail_processors.scale_and_crop_with_subject_location", diff --git a/src/open_inwoner/configurations/models.py b/src/open_inwoner/configurations/models.py index 6ca9b3a130..829ef07faf 100644 --- a/src/open_inwoner/configurations/models.py +++ b/src/open_inwoner/configurations/models.py @@ -7,7 +7,6 @@ from colorfield.fields import ColorField from django_better_admin_arrayfield.models.fields import ArrayField -from filer.fields.file import FilerFileField from filer.fields.image import FilerImageField from ordered_model.models import OrderedModel, OrderedModelManager from solo.models import SingletonModel diff --git a/src/open_inwoner/extended_sessions/tests/test_views.py b/src/open_inwoner/extended_sessions/tests/test_views.py index add8d7a45d..081ee1fecb 100644 --- a/src/open_inwoner/extended_sessions/tests/test_views.py +++ b/src/open_inwoner/extended_sessions/tests/test_views.py @@ -1,4 +1,3 @@ -from django.test import TestCase from django.urls import reverse from django_webtest import WebTest diff --git a/src/open_inwoner/haalcentraal/apps.py b/src/open_inwoner/haalcentraal/apps.py index 880babdb24..b9ffe635a5 100644 --- a/src/open_inwoner/haalcentraal/apps.py +++ b/src/open_inwoner/haalcentraal/apps.py @@ -1,9 +1,8 @@ from django.apps import AppConfig -from django.utils.translation import ugettext_lazy as _ class HaalCentraalConfig(AppConfig): name = "open_inwoner.haalcentraal" def ready(self): - from .signals import on_bsn_change + from .signals import on_bsn_change # noqa diff --git a/src/open_inwoner/haalcentraal/tests/test_signal.py b/src/open_inwoner/haalcentraal/tests/test_signal.py index 2a0325019b..d37f0c9226 100644 --- a/src/open_inwoner/haalcentraal/tests/test_signal.py +++ b/src/open_inwoner/haalcentraal/tests/test_signal.py @@ -1,5 +1,4 @@ import logging -from datetime import date from django.test import TestCase, override_settings from django.utils.translation import gettext as _ diff --git a/src/open_inwoner/kvk/apps.py b/src/open_inwoner/kvk/apps.py index 577a849152..ec8eb9fb04 100644 --- a/src/open_inwoner/kvk/apps.py +++ b/src/open_inwoner/kvk/apps.py @@ -1,9 +1,8 @@ from django.apps import AppConfig -from django.utils.translation import ugettext_lazy as _ class KvKConfig(AppConfig): name = "open_inwoner.kvk" def ready(self): - from .signals import on_kvk_change + from .signals import on_kvk_change # noqa diff --git a/src/open_inwoner/openklant/tests/test_contactform.py b/src/open_inwoner/openklant/tests/test_contactform.py index fdde508708..a1a20e64db 100644 --- a/src/open_inwoner/openklant/tests/test_contactform.py +++ b/src/open_inwoner/openklant/tests/test_contactform.py @@ -268,7 +268,7 @@ def test_submit_and_register_anon_via_api_with_klant(self, m): { "medewerkerIdentificatie": {"identificatie": "FooVonBar"}, "bronorganisatie": "123456789", - "tekst": f"Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", + "tekst": "Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", "type": "Melding", "kanaal": "Internet", "onderwerp": "afdeling-xyz", @@ -413,7 +413,7 @@ def test_submit_and_register_bsn_user_via_api(self, m): { "medewerkerIdentificatie": {"identificatie": "FooVonBar"}, "bronorganisatie": "123456789", - "tekst": f"Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", + "tekst": "Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", "type": "Melding", "kanaal": "Internet", "onderwerp": "afdeling-xyz", @@ -503,7 +503,7 @@ def test_submit_and_register_kvk_or_rsin_user_via_api(self, _m): { "medewerkerIdentificatie": {"identificatie": "FooVonBar"}, "bronorganisatie": "123456789", - "tekst": f"Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", + "tekst": "Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", "type": "Melding", "kanaal": "Internet", "onderwerp": "afdeling-xyz", @@ -579,7 +579,7 @@ def test_submit_and_register_bsn_user_via_api_and_update_klant(self, m): { "medewerkerIdentificatie": {"identificatie": "FooVonBar"}, "bronorganisatie": "123456789", - "tekst": f"Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", + "tekst": "Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", "type": "Melding", "kanaal": "Internet", "onderwerp": "afdeling-xyz", @@ -675,7 +675,7 @@ def test_submit_and_register_kvk_or_rsin_user_via_api_and_update_klant(self, _m) { "medewerkerIdentificatie": {"identificatie": "FooVonBar"}, "bronorganisatie": "123456789", - "tekst": f"Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", + "tekst": "Onderwerp: Aanvraag document\n\nhey!\n\nwaddup?", "type": "Melding", "kanaal": "Internet", "onderwerp": "afdeling-xyz", diff --git a/src/open_inwoner/openklant/tests/test_signal.py b/src/open_inwoner/openklant/tests/test_signal.py index c4961f0555..786e693cdb 100644 --- a/src/open_inwoner/openklant/tests/test_signal.py +++ b/src/open_inwoner/openklant/tests/test_signal.py @@ -1,5 +1,5 @@ from django.contrib.auth import user_logged_in -from django.test import RequestFactory, override_settings +from django.test import RequestFactory import requests_mock from django_webtest import WebTest diff --git a/src/open_inwoner/openzaak/clients.py b/src/open_inwoner/openzaak/clients.py index 23dee2160c..7f17c6b173 100644 --- a/src/open_inwoner/openzaak/clients.py +++ b/src/open_inwoner/openzaak/clients.py @@ -16,7 +16,6 @@ from zgw_consumers.service import pagination_helper from open_inwoner.openzaak.api_models import InformatieObject -from open_inwoner.openzaak.models import OpenZaakConfig from open_inwoner.utils.api import ClientError, get_json_response from ..utils.decorators import cache as cache_result diff --git a/src/open_inwoner/openzaak/documents.py b/src/open_inwoner/openzaak/documents.py index 74410b9ae7..ddf7dda690 100644 --- a/src/open_inwoner/openzaak/documents.py +++ b/src/open_inwoner/openzaak/documents.py @@ -3,8 +3,6 @@ from django.conf import settings -from zgw_consumers.client import build_client - from open_inwoner.openzaak.api_models import InformatieObject from open_inwoner.openzaak.clients import build_client diff --git a/src/open_inwoner/openzaak/management/commands/zgw_dev_status.py b/src/open_inwoner/openzaak/management/commands/zgw_dev_status.py index 5e3824d56d..ce2b2dd81b 100644 --- a/src/open_inwoner/openzaak/management/commands/zgw_dev_status.py +++ b/src/open_inwoner/openzaak/management/commands/zgw_dev_status.py @@ -172,7 +172,7 @@ def handle(self, *args, **options): { "zaak": case.url, "resultaattype": next_result_type.url, - "toelichting": f"set from management command", + "toelichting": "set from management command", }, ) @@ -182,7 +182,7 @@ def handle(self, *args, **options): "zaak": case.url, "statustype": next_status_type.url, "datumStatusGezet": timezone.now().isoformat(), - "statustoelichting": f"set from management command", + "statustoelichting": "set from management command", }, ) diff --git a/src/open_inwoner/openzaak/models.py b/src/open_inwoner/openzaak/models.py index e27bd775f0..f2c971d4cb 100644 --- a/src/open_inwoner/openzaak/models.py +++ b/src/open_inwoner/openzaak/models.py @@ -289,7 +289,7 @@ def __str__(self): self.identificatie, self.omschrijving, ) - return f" - ".join(b for b in bits if b) + return " - ".join(b for b in bits if b) class ZaakTypeInformatieObjectTypeConfig(models.Model): diff --git a/src/open_inwoner/openzaak/tests/test_documents.py b/src/open_inwoner/openzaak/tests/test_documents.py index a2e5a24fc9..98c0838472 100644 --- a/src/open_inwoner/openzaak/tests/test_documents.py +++ b/src/open_inwoner/openzaak/tests/test_documents.py @@ -213,7 +213,7 @@ def test_document_content_is_retrieved_when_user_logged_in_via_digid(self, m): self.assertIn("Content-Disposition", response.headers) self.assertEqual( response.headers["Content-Disposition"], - f'attachment; filename="my_document.txt"', + 'attachment; filename="my_document.txt"', ) self.assertIn("Content-Type", response.headers) self.assertEqual(response.headers["Content-Type"], "text/plain") diff --git a/src/open_inwoner/openzaak/tests/test_notification_data.py b/src/open_inwoner/openzaak/tests/test_notification_data.py index d41454a5f3..80fcef5c7c 100644 --- a/src/open_inwoner/openzaak/tests/test_notification_data.py +++ b/src/open_inwoner/openzaak/tests/test_notification_data.py @@ -11,12 +11,7 @@ DigidUserFactory, eHerkenningUserFactory, ) -from open_inwoner.openzaak.tests.factories import ( - NotificationFactory, - ServiceFactory, - ZaakTypeConfigFactory, - ZaakTypeInformatieObjectTypeConfigFactory, -) +from open_inwoner.openzaak.tests.factories import NotificationFactory, ServiceFactory from open_inwoner.utils.test import paginated_response from ..models import OpenZaakConfig diff --git a/src/open_inwoner/openzaak/tests/test_notification_zaak_infoobject.py b/src/open_inwoner/openzaak/tests/test_notification_zaak_infoobject.py index 7166e6dbe1..32b282c32a 100644 --- a/src/open_inwoner/openzaak/tests/test_notification_zaak_infoobject.py +++ b/src/open_inwoner/openzaak/tests/test_notification_zaak_infoobject.py @@ -22,11 +22,7 @@ from open_inwoner.utils.tests.helpers import AssertTimelineLogMixin, Lookups from ..api_models import InformatieObject, Zaak, ZaakInformatieObject, ZaakType -from ..models import ( - OpenZaakConfig, - UserCaseInfoObjectNotification, - ZaakTypeInformatieObjectTypeConfig, -) +from ..models import OpenZaakConfig, UserCaseInfoObjectNotification from .helpers import copy_with_new_uuid from .test_notification_data import MockAPIData @@ -173,7 +169,7 @@ def test_zio_bails_when_cannot_fetch_case(self, m, mock_handle: Mock): mock_handle.assert_not_called() self.assertTimelineLog( - f"ignored zaakinformatieobject notification: cannot retrieve case https://", + "ignored zaakinformatieobject notification: cannot retrieve case https://", lookup=Lookups.startswith, level=logging.ERROR, ) @@ -186,7 +182,7 @@ def test_zio_bails_when_cannot_fetch_case_type(self, m, mock_handle: Mock): mock_handle.assert_not_called() self.assertTimelineLog( - f"ignored zaakinformatieobject notification: cannot retrieve case_type https://", + "ignored zaakinformatieobject notification: cannot retrieve case_type https://", lookup=Lookups.startswith, level=logging.ERROR, ) @@ -202,7 +198,7 @@ def test_zio_bails_when_case_not_visible_because_confidentiality( mock_handle.assert_not_called() self.assertTimelineLog( - f"ignored zaakinformatieobject notification: case not visible after applying website visibility filter for case https://", + "ignored zaakinformatieobject notification: case not visible after applying website visibility filter for case https://", lookup=Lookups.startswith, level=logging.INFO, ) @@ -218,7 +214,7 @@ def test_zio_bails_when_case_not_visible_because_internal_case( mock_handle.assert_not_called() self.assertTimelineLog( - f"ignored zaakinformatieobject notification: case not visible after applying website visibility filter for case https://", + "ignored zaakinformatieobject notification: case not visible after applying website visibility filter for case https://", lookup=Lookups.startswith, level=logging.INFO, ) @@ -267,7 +263,7 @@ def test_zio_bails_when_info_object_not_visible_because_confidentiality( mock_handle.assert_not_called() self.assertTimelineLog( - f"ignored zaakinformatieobject notification: informatieobject not visible after applying website visibility filter for case https://", + "ignored zaakinformatieobject notification: informatieobject not visible after applying website visibility filter for case https://", lookup=Lookups.startswith, level=logging.INFO, ) @@ -283,7 +279,7 @@ def test_zio_bails_when_info_object_not_visible_because_not_definitive( mock_handle.assert_not_called() self.assertTimelineLog( - f"ignored zaakinformatieobject notification: informatieobject not visible after applying website visibility filter for case https://", + "ignored zaakinformatieobject notification: informatieobject not visible after applying website visibility filter for case https://", lookup=Lookups.startswith, level=logging.INFO, ) diff --git a/src/open_inwoner/openzaak/tests/test_notification_zaak_status.py b/src/open_inwoner/openzaak/tests/test_notification_zaak_status.py index 4f174a189c..e5239d3856 100644 --- a/src/open_inwoner/openzaak/tests/test_notification_zaak_status.py +++ b/src/open_inwoner/openzaak/tests/test_notification_zaak_status.py @@ -142,7 +142,7 @@ def test_status_bails_when_cannot_fetch_case(self, m, mock_handle: Mock): mock_handle.assert_not_called() self.assertTimelineLog( - f"ignored status notification: cannot retrieve case https://", + "ignored status notification: cannot retrieve case https://", lookup=Lookups.startswith, level=logging.ERROR, ) @@ -155,7 +155,7 @@ def test_status_bails_when_cannot_fetch_case_type(self, m, mock_handle: Mock): mock_handle.assert_not_called() self.assertTimelineLog( - f"ignored status notification: cannot retrieve case_type https://", + "ignored status notification: cannot retrieve case_type https://", lookup=Lookups.startswith, level=logging.ERROR, ) @@ -171,7 +171,7 @@ def test_status_bails_when_case_not_visible_because_confidentiality( mock_handle.assert_not_called() self.assertTimelineLog( - f"ignored status notification: case not visible after applying website visibility filter for case https://", + "ignored status notification: case not visible after applying website visibility filter for case https://", lookup=Lookups.startswith, level=logging.INFO, ) @@ -187,7 +187,7 @@ def test_status_bails_when_case_not_visible_because_internal_case( mock_handle.assert_not_called() self.assertTimelineLog( - f"ignored status notification: case not visible after applying website visibility filter for case https://", + "ignored status notification: case not visible after applying website visibility filter for case https://", lookup=Lookups.startswith, level=logging.INFO, ) @@ -204,7 +204,7 @@ def test_status_bails_when_cannot_fetch_status_history(self, m, mock_handle: Moc mock_handle.assert_not_called() self.assertTimelineLog( - f"ignored status notification: cannot retrieve status_history for case https://", + "ignored status notification: cannot retrieve status_history for case https://", lookup=Lookups.startswith, level=logging.ERROR, ) @@ -220,7 +220,7 @@ def test_status_bails_when_status_history_is_single_initial_item( mock_handle.assert_not_called() self.assertTimelineLog( - f"ignored status notification: skip initial status notification for case https://", + "ignored status notification: skip initial status notification for case https://", lookup=Lookups.startswith, level=logging.INFO, ) diff --git a/src/open_inwoner/openzaak/tests/test_utils.py b/src/open_inwoner/openzaak/tests/test_utils.py index fc4e6c4901..d04ea8968b 100644 --- a/src/open_inwoner/openzaak/tests/test_utils.py +++ b/src/open_inwoner/openzaak/tests/test_utils.py @@ -80,7 +80,7 @@ def test_is_info_object_visible(self): ) # test we don't leak on bad input - with self.subTest(f"bad vertrouwelijkheidaanduiding in info object"): + with self.subTest("bad vertrouwelijkheidaanduiding in info object"): info_object = factory( InformatieObject, generate_oas_component( @@ -92,7 +92,7 @@ def test_is_info_object_visible(self): ) self.assertFalse(is_info_object_visible(info_object, max_level)) - with self.subTest(f"bad vertrouwelijkheidaanduiding as parameter"): + with self.subTest("bad vertrouwelijkheidaanduiding as parameter"): info_object = factory( InformatieObject, generate_oas_component( diff --git a/src/open_inwoner/openzaak/tests/test_zgw_imports.py b/src/open_inwoner/openzaak/tests/test_zgw_imports.py index cc6bc974f2..e3e5edd2f9 100644 --- a/src/open_inwoner/openzaak/tests/test_zgw_imports.py +++ b/src/open_inwoner/openzaak/tests/test_zgw_imports.py @@ -2,7 +2,6 @@ import requests_mock from zgw_consumers.constants import APITypes -from zgw_consumers.test import generate_oas_component from open_inwoner.openzaak.models import CatalogusConfig, OpenZaakConfig, ZaakTypeConfig from open_inwoner.openzaak.tests.factories import CatalogusConfigFactory, ServiceFactory diff --git a/src/open_inwoner/openzaak/utils.py b/src/open_inwoner/openzaak/utils.py index ea372b4bd7..97fc8a64ac 100644 --- a/src/open_inwoner/openzaak/utils.py +++ b/src/open_inwoner/openzaak/utils.py @@ -1,6 +1,5 @@ import logging -from typing import Optional, Union -from uuid import UUID +from typing import Optional from zgw_consumers.api_models.constants import RolTypes, VertrouwelijkheidsAanduidingen diff --git a/src/open_inwoner/pdc/admin/__init__.py b/src/open_inwoner/pdc/admin/__init__.py index bfb2f975f6..3822e81e5a 100644 --- a/src/open_inwoner/pdc/admin/__init__.py +++ b/src/open_inwoner/pdc/admin/__init__.py @@ -1,6 +1,6 @@ -from .category import * -from .faq import * -from .neighbourhood import * -from .organization import * -from .product import * -from .tag import * +from .category import * # noqa +from .faq import * # noqa +from .neighbourhood import * # noqa +from .organization import * # noqa +from .product import * # noqa +from .tag import * # noqa diff --git a/src/open_inwoner/pdc/admin/category.py b/src/open_inwoner/pdc/admin/category.py index 58b7aba6a5..bfd7dd5728 100644 --- a/src/open_inwoner/pdc/admin/category.py +++ b/src/open_inwoner/pdc/admin/category.py @@ -2,7 +2,6 @@ from django import forms from django.contrib import admin -from django.core.exceptions import ValidationError from django.forms import BaseModelFormSet from django.utils.translation import gettext as _ diff --git a/src/open_inwoner/pdc/managers.py b/src/open_inwoner/pdc/managers.py index c0e38b57a9..918b438933 100644 --- a/src/open_inwoner/pdc/managers.py +++ b/src/open_inwoner/pdc/managers.py @@ -114,7 +114,7 @@ def filter_by_zaken(self, cases: List[Zaak]): pks = [] for category in qs: for identificatie in category.zaaktypen: - if not identificatie in months_since_last_zaak_per_zaaktype: + if identificatie not in months_since_last_zaak_per_zaaktype: continue relevante_zaakperiode = zaakperiode_mapping.get(identificatie) if not relevante_zaakperiode: diff --git a/src/open_inwoner/pdc/models/__init__.py b/src/open_inwoner/pdc/models/__init__.py index bfb2f975f6..1466581d0d 100644 --- a/src/open_inwoner/pdc/models/__init__.py +++ b/src/open_inwoner/pdc/models/__init__.py @@ -1,6 +1,31 @@ -from .category import * -from .faq import * -from .neighbourhood import * -from .organization import * -from .product import * -from .tag import * +from .category import Category +from .faq import Question +from .neighbourhood import Neighbourhood +from .organization import Organization, OrganizationType +from .product import ( + CategoryProduct, + Product, + ProductCondition, + ProductContact, + ProductFile, + ProductLink, + ProductLocation, +) +from .tag import Tag, TagType + +__all__ = [ + "Category", + "Question", + "Neighbourhood", + "Organization", + "OrganizationType", + "CategoryProduct", + "Product", + "ProductCondition", + "ProductContact", + "ProductFile", + "ProductLink", + "ProductLocation", + "Tag", + "TagType", +] diff --git a/src/open_inwoner/pdc/models/category.py b/src/open_inwoner/pdc/models/category.py index 2ff8a732f4..a9783500c6 100644 --- a/src/open_inwoner/pdc/models/category.py +++ b/src/open_inwoner/pdc/models/category.py @@ -7,7 +7,6 @@ from treebeard.exceptions import InvalidMoveToDescendant from treebeard.mp_tree import MP_MoveHandler, MP_Node -from ...utils.ckeditor import get_rendered_content from ..managers import CategoryPublishedQueryset diff --git a/src/open_inwoner/pdc/models/product.py b/src/open_inwoner/pdc/models/product.py index 6c511c9069..4816fafca7 100644 --- a/src/open_inwoner/pdc/models/product.py +++ b/src/open_inwoner/pdc/models/product.py @@ -1,4 +1,3 @@ -import html import json from typing import Union from uuid import uuid4 @@ -6,7 +5,6 @@ from django.contrib.postgres.fields import ArrayField from django.db import models from django.urls import reverse -from django.utils.html import strip_tags from django.utils.translation import ugettext_lazy as _ from filer.fields.file import FilerFileField @@ -232,7 +230,7 @@ def get_absolute_url(self, category=None): ) def has_cta_tag(self): - return "\[CTABUTTON\]" in self.content + return "\[CTABUTTON\]" in self.content # noqa class ProductFile(models.Model): diff --git a/src/open_inwoner/pdc/resources/__init__.py b/src/open_inwoner/pdc/resources/__init__.py index 7a2de252d9..79f5621f92 100644 --- a/src/open_inwoner/pdc/resources/__init__.py +++ b/src/open_inwoner/pdc/resources/__init__.py @@ -1,2 +1,9 @@ from .export_resource import CategoryExportResource, ProductExportResource from .import_resource import CategoryImportResource, ProductImportResource + +__all__ = [ + "CategoryExportResource", + "ProductExportResource", + "CategoryImportResource", + "ProductImportResource", +] diff --git a/src/open_inwoner/pdc/tests/test_product.py b/src/open_inwoner/pdc/tests/test_product.py index f737f532e4..bf438f54be 100644 --- a/src/open_inwoner/pdc/tests/test_product.py +++ b/src/open_inwoner/pdc/tests/test_product.py @@ -268,7 +268,7 @@ def test_button_text_change(self): def test_sidemenu_button_is_not_rendered_when_cta_inside_product_content(self): product = ProductFactory( - content="Some content \[CTABUTTON\]", link="http://www.example.com" + content="Some content \[CTABUTTON\]", link="http://www.example.com" # noqa ) response = self.app.get( diff --git a/src/open_inwoner/pdc/tests/test_product_resources.py b/src/open_inwoner/pdc/tests/test_product_resources.py index 9feb6ab70d..80eb5720f2 100644 --- a/src/open_inwoner/pdc/tests/test_product_resources.py +++ b/src/open_inwoner/pdc/tests/test_product_resources.py @@ -1,5 +1,4 @@ from collections import OrderedDict -from decimal import Decimal from django.core.exceptions import ValidationError from django.test import TestCase diff --git a/src/open_inwoner/pdc/tests/test_views.py b/src/open_inwoner/pdc/tests/test_views.py index 0f81281923..00cc0b7c2e 100644 --- a/src/open_inwoner/pdc/tests/test_views.py +++ b/src/open_inwoner/pdc/tests/test_views.py @@ -1,5 +1,3 @@ -from unittest import skip - from django.conf import settings from django.test import TestCase, override_settings from django.urls import reverse diff --git a/src/open_inwoner/plans/tests/test_views.py b/src/open_inwoner/plans/tests/test_views.py index bb05b08f95..0049b92067 100644 --- a/src/open_inwoner/plans/tests/test_views.py +++ b/src/open_inwoner/plans/tests/test_views.py @@ -480,7 +480,7 @@ def test_plan_create_plan_validation_error_reselects_template_and_contact(self): self.assertEqual(elem.attrib.get("checked"), "checked") # NOTE: custom widget ID hardcoded on index of choice - elem = response.pyquery(f"#id_plan_contacts_1")[0] + elem = response.pyquery("#id_plan_contacts_1")[0] self.assertEqual(elem.attrib.get("checked"), "checked") def test_plan_create_contains_contact_create_link_when_no_contacts_exist(self): diff --git a/src/open_inwoner/questionnaire/tests/test_views.py b/src/open_inwoner/questionnaire/tests/test_views.py index 014b352d51..2b38f23879 100644 --- a/src/open_inwoner/questionnaire/tests/test_views.py +++ b/src/open_inwoner/questionnaire/tests/test_views.py @@ -6,7 +6,6 @@ from django.urls import reverse from django.views.generic import FormView -from cms import api from django_webtest import WebTest from ...accounts.tests.factories import UserFactory diff --git a/src/open_inwoner/search/forms.py b/src/open_inwoner/search/forms.py index 66130f01e1..d1b3b82ccb 100644 --- a/src/open_inwoner/search/forms.py +++ b/src/open_inwoner/search/forms.py @@ -1,10 +1,6 @@ from django import forms -from django.forms import widgets -from django.forms.widgets import Textarea from django.utils.translation import ugettext_lazy as _ -from open_inwoner.components.templatetags.form_tags import form - from .models import Feedback diff --git a/src/open_inwoner/search/models.py b/src/open_inwoner/search/models.py index 7f1d40fcc1..ee4e21ac20 100644 --- a/src/open_inwoner/search/models.py +++ b/src/open_inwoner/search/models.py @@ -4,7 +4,6 @@ from django.utils.translation import ugettext_lazy as _ from django_better_admin_arrayfield.models.fields import ArrayField -from solo.models import SingletonModel from .query import FieldBoostQueryset diff --git a/src/open_inwoner/search/resources/__init__.py b/src/open_inwoner/search/resources/__init__.py index fab0f02169..f99689607a 100644 --- a/src/open_inwoner/search/resources/__init__.py +++ b/src/open_inwoner/search/resources/__init__.py @@ -1 +1,5 @@ from .resources import SynonymResource + +__all__ = [ + "SynonymResource", +] diff --git a/src/open_inwoner/search/results.py b/src/open_inwoner/search/results.py index 523e384b99..647df553e9 100644 --- a/src/open_inwoner/search/results.py +++ b/src/open_inwoner/search/results.py @@ -52,7 +52,7 @@ def generate_buckets(self, init_buckets: list): ) ) else: - raise NotImplemented("Bucket shape is unknown") + raise NotImplementedError("Bucket shape is unknown") return buckets diff --git a/src/open_inwoner/search/tests/test_feedback.py b/src/open_inwoner/search/tests/test_feedback.py index 4629abedfd..d1b69e8d79 100644 --- a/src/open_inwoner/search/tests/test_feedback.py +++ b/src/open_inwoner/search/tests/test_feedback.py @@ -44,7 +44,7 @@ def test_positive_feedback_is_saved_with_authenticated_user_and_without_filters( feedback = Feedback.objects.get() - self.assertEqual(feedback.search_query, f"query: keyword1") + self.assertEqual(feedback.search_query, "query: keyword1") self.assertEqual(feedback.search_url, url) self.assertTrue(feedback.positive) self.assertEqual(feedback.remark, "Some remark") @@ -65,7 +65,7 @@ def test_negative_feedback_is_saved_with_authenticated_user_and_without_filters( feedback = Feedback.objects.get() - self.assertEqual(feedback.search_query, f"query: keyword1") + self.assertEqual(feedback.search_query, "query: keyword1") self.assertEqual(feedback.search_url, url) self.assertFalse(feedback.positive) self.assertEqual(feedback.remark, "Some remark") @@ -85,7 +85,7 @@ def test_positive_feedback_is_saved_with_unauthenticated_user_and_without_filter feedback = Feedback.objects.get() - self.assertEqual(feedback.search_query, f"query: keyword1") + self.assertEqual(feedback.search_query, "query: keyword1") self.assertEqual(feedback.search_url, url) self.assertTrue(feedback.positive) self.assertEqual(feedback.remark, "Some remark") @@ -105,7 +105,7 @@ def test_negative_feedback_is_saved_with_unauthenticated_user_and_without_filter feedback = Feedback.objects.get() - self.assertEqual(feedback.search_query, f"query: keyword1") + self.assertEqual(feedback.search_query, "query: keyword1") self.assertEqual(feedback.search_url, url) self.assertFalse(feedback.positive) self.assertEqual(feedback.remark, "Some remark") @@ -160,7 +160,7 @@ def test_positive_feedback_is_saved_with_unauthenticated_user_and_with_filters( feedback = Feedback.objects.get() - self.assertEqual(feedback.search_query, f"query: keyword1") + self.assertEqual(feedback.search_query, "query: keyword1") self.assertEqual(feedback.search_url, url) self.assertTrue(feedback.positive) self.assertEqual(feedback.remark, "Some remark") diff --git a/src/open_inwoner/userfeed/apps.py b/src/open_inwoner/userfeed/apps.py index e68053282f..1c6e6c163b 100644 --- a/src/open_inwoner/userfeed/apps.py +++ b/src/open_inwoner/userfeed/apps.py @@ -1,7 +1,3 @@ -import os -from importlib import import_module -from pathlib import Path - from django.apps import AppConfig diff --git a/src/open_inwoner/userfeed/hooks/__init__.py b/src/open_inwoner/userfeed/hooks/__init__.py index 5ffb0d9fb4..6f35f072e5 100644 --- a/src/open_inwoner/userfeed/hooks/__init__.py +++ b/src/open_inwoner/userfeed/hooks/__init__.py @@ -10,3 +10,16 @@ ) from .common import simple_message from .plan import PlanExpiresFeedItem, plan_completed, plan_expiring + +__all__ = [ + "CaseDocumentAddedFeedItem", + "case_document_added_notification_received", + "case_documents_seen", + "CaseStatusUpdateFeedItem", + "case_status_notification_received", + "case_status_seen", + "simple_message", + "PlanExpiresFeedItem", + "plan_completed", + "plan_expiring", +] diff --git a/src/open_inwoner/userfeed/tests/test_commands.py b/src/open_inwoner/userfeed/tests/test_commands.py index 6314b6998e..ef6cdf57a1 100644 --- a/src/open_inwoner/userfeed/tests/test_commands.py +++ b/src/open_inwoner/userfeed/tests/test_commands.py @@ -1,5 +1,5 @@ from datetime import datetime -from unittest.mock import Mock, patch +from unittest.mock import patch from django.core.management import call_command from django.test import TestCase diff --git a/src/open_inwoner/userfeed/tests/test_feed.py b/src/open_inwoner/userfeed/tests/test_feed.py index 4af98cfcf3..0d5d7bfdef 100644 --- a/src/open_inwoner/userfeed/tests/test_feed.py +++ b/src/open_inwoner/userfeed/tests/test_feed.py @@ -1,7 +1,7 @@ from django.test import TestCase from django.utils import timezone from django.utils.html import strip_tags -from django.utils.translation import ngettext, ugettext as _ +from django.utils.translation import ngettext from freezegun import freeze_time diff --git a/src/open_inwoner/utils/apps.py b/src/open_inwoner/utils/apps.py index c272b37a9c..dd49e28088 100644 --- a/src/open_inwoner/utils/apps.py +++ b/src/open_inwoner/utils/apps.py @@ -6,4 +6,4 @@ class UtilsConfig(AppConfig): def ready(self): from . import checks # noqa - from .signals import copy_log_entry_to_timeline_logger + from .signals import copy_log_entry_to_timeline_logger # noqa diff --git a/src/open_inwoner/utils/tests/test_timeline_logger.py b/src/open_inwoner/utils/tests/test_timeline_logger.py index 363cba0e14..837d262c12 100644 --- a/src/open_inwoner/utils/tests/test_timeline_logger.py +++ b/src/open_inwoner/utils/tests/test_timeline_logger.py @@ -72,7 +72,7 @@ def test_changed_object_is_logged(self): { "message": "Titel, Doel and Einddatum gewijzigd.", "action_flag": list(LOG_ACTIONS[CHANGE]), - "content_object_repr": f"Updated", + "content_object_repr": "Updated", }, ) diff --git a/src/open_inwoner/utils/translate.py b/src/open_inwoner/utils/translate.py index 5755ac07f5..526c5c5e5e 100644 --- a/src/open_inwoner/utils/translate.py +++ b/src/open_inwoner/utils/translate.py @@ -1,4 +1,4 @@ -from typing import Any, Iterable, Optional, Tuple +from typing import Any, Iterable, Tuple from glom import glom diff --git a/src/open_inwoner/wsgi.py b/src/open_inwoner/wsgi.py index 8f5aafb7ed..3b583ce601 100644 --- a/src/open_inwoner/wsgi.py +++ b/src/open_inwoner/wsgi.py @@ -6,8 +6,6 @@ For more information on this file, see https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/ """ -import os - from django.core.wsgi import get_wsgi_application from open_inwoner.setup import setup_env