Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! [WIP] pre-com…
Browse files Browse the repository at this point in the history
…mit and ruff
  • Loading branch information
swrichards committed Jan 7, 2025
1 parent 83319d3 commit d51dce7
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 54 deletions.
11 changes: 10 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@ repos:
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
# - id: ruff-format
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 22.12.0
hooks:
- id: black
language_version: python3.11
3 changes: 2 additions & 1 deletion src/open_inwoner/accounts/notifications/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@


class Notifier(typing.Protocol):
def __call__(self, receiver: User, object_ids: list[int], channel: str) -> None: ...
def __call__(self, receiver: User, object_ids: list[int], channel: str) -> None:
...
30 changes: 15 additions & 15 deletions src/open_inwoner/accounts/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def test_digid_fail_with_invite_redirects_to_register_page(self, m):
m.return_value = True
invite = InviteFactory()
session = self.client.session
session["invite_url"] = (
f"{reverse('django_registration_register')}?invite={invite.key}"
)
session[
"invite_url"
] = f"{reverse('django_registration_register')}?invite={invite.key}"
session.save()

url = reverse("digid-mock:password")
Expand All @@ -179,9 +179,9 @@ def test_digid_fail_with_invite_redirects_to_register_page(self, m):
def test_invite_url_not_in_session_after_successful_login(self):
invite = InviteFactory()
session = self.client.session
session["invite_url"] = (
f"{reverse('django_registration_register')}?invite={invite.key}"
)
session[
"invite_url"
] = f"{reverse('django_registration_register')}?invite={invite.key}"
session.save()

url = reverse("digid-mock:password")
Expand Down Expand Up @@ -283,9 +283,9 @@ def test_notification_settings_with_cms_page_published(self, m):
self.assertNotIn("messages_notifications", necessary_form.fields)

necessary_form["plans_notifications"] = False
necessary_form["case_notification_channel"] = (
NotificationChannelChoice.digital_only
)
necessary_form[
"case_notification_channel"
] = NotificationChannelChoice.digital_only
necessary_form.submit()

user = User.objects.get(bsn=data["auth_name"])
Expand Down Expand Up @@ -668,9 +668,9 @@ def test_eherkenning_fail_with_invite_redirects_to_register_page(self, m):
m.return_value = True
invite = InviteFactory()
session = self.client.session
session["invite_url"] = (
f"{reverse('django_registration_register')}?invite={invite.key}"
)
session[
"invite_url"
] = f"{reverse('django_registration_register')}?invite={invite.key}"
session.save()

url = reverse("eherkenning-mock:password")
Expand Down Expand Up @@ -722,9 +722,9 @@ def test_invite_url_not_in_session_after_successful_login(

invite = InviteFactory()
session = self.client.session
session["invite_url"] = (
f"{reverse('django_registration_register')}?invite={invite.key}"
)
session[
"invite_url"
] = f"{reverse('django_registration_register')}?invite={invite.key}"
session.save()

url = reverse("eherkenning-mock:password")
Expand Down
6 changes: 2 additions & 4 deletions src/open_inwoner/cms/cases/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ def __init__(self, case, **kwargs):
if case:
self.fields[
"type"
].queryset = (
ZaakTypeInformatieObjectTypeConfig.objects.filter_enabled_for_case_type(
case.zaaktype
)
].queryset = ZaakTypeInformatieObjectTypeConfig.objects.filter_enabled_for_case_type(
case.zaaktype
)

choices = self.fields["type"].choices
Expand Down
6 changes: 3 additions & 3 deletions src/open_inwoner/cms/cases/views/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,9 +911,9 @@ def post(self, request, *args, **kwargs):
send_confirmation = False

if config.register_email:
form.cleaned_data["question"] += (
f"\n\nCase number: {self.case.identificatie}"
)
form.cleaned_data[
"question"
] += f"\n\nCase number: {self.case.identificatie}"
email_success = self.register_by_email(form, config.register_email)
send_confirmation = email_success

Expand Down
3 changes: 1 addition & 2 deletions src/open_inwoner/cms/extensions/cms_menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb):
pages = (
Page.objects.filter(id__in=page_nodes.keys())
# optimise and only retrieve id and related object
.only("id")
.select_related("commonextension")
.only("id").select_related("commonextension")
)
num_indicators = 0

Expand Down
6 changes: 3 additions & 3 deletions src/open_inwoner/components/templatetags/action_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def action_status_button(action, request, plan=None, **kwargs):
for value, label, icon in StatusChoices.choices_with_icons()
]

kwargs["class"] = (
f"actions__status-selector actions__status-selector--{action.status}"
)
kwargs[
"class"
] = f"actions__status-selector actions__status-selector--{action.status}"
kwargs.update(
action=action,
request=request,
Expand Down
3 changes: 2 additions & 1 deletion src/open_inwoner/configurations/bootstrap/cms.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def configure(self):

cms_tools.create_apphook_page(self.app_hook, extension_args=extension_args)

def test_configuration(self): ...
def test_configuration(self):
...


class CMSConfigSettings(ConfigSettings):
Expand Down
3 changes: 2 additions & 1 deletion src/open_inwoner/configurations/bootstrap/siteconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,5 @@ def configure(self):

form.save()

def test_configuration(self): ...
def test_configuration(self):
...
18 changes: 9 additions & 9 deletions src/open_inwoner/openklant/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,18 +305,18 @@ def update_user_from_klant(self, klant: Klant, user: User):
and user.case_notification_channel
!= NotificationChannelChoice.digital_only
):
update_data["case_notification_channel"] = (
NotificationChannelChoice.digital_only
)
update_data[
"case_notification_channel"
] = NotificationChannelChoice.digital_only

elif (
klant.toestemming_zaak_notificaties_alleen_digitaal is False
and user.case_notification_channel
!= NotificationChannelChoice.digital_and_post
):
update_data["case_notification_channel"] = (
NotificationChannelChoice.digital_and_post
)
update_data[
"case_notification_channel"
] = NotificationChannelChoice.digital_and_post
else:
# This is a guard against the scenario where a deployment is
# configured to use an older version of the klanten backend (that
Expand Down Expand Up @@ -1252,9 +1252,9 @@ def questions_for_partij(self, partij_uuid: str) -> list[OpenKlant2Question]:
for klantcontact in self.klantcontacten_for_partij(
partij_uuid, kanaal=self.config.mijn_vragen_kanaal
):
klantcontact_uuid_to_klantcontact_object[klantcontact["uuid"]] = (
klantcontact
)
klantcontact_uuid_to_klantcontact_object[
klantcontact["uuid"]
] = klantcontact

# A klantcontact is an answer if it is linked to a Question via an onderwerp object
if onderwerp_objecten := klantcontact["gingOverOnderwerpobjecten"]:
Expand Down
12 changes: 6 additions & 6 deletions src/open_inwoner/openzaak/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ def export_catalogus_configs(modeladmin, request, queryset):
export.as_jsonl_iter(),
content_type="application/json",
)
response["Content-Disposition"] = (
'attachment; filename="zgw-catalogi-export.json"'
)
response[
"Content-Disposition"
] = 'attachment; filename="zgw-catalogi-export.json"'
return response

def process_file_view(self, request):
Expand Down Expand Up @@ -453,9 +453,9 @@ def export_zaaktype_configs(modeladmin, request, queryset):
export.as_jsonl_iter(),
content_type="application/json",
)
response["Content-Disposition"] = (
'attachment; filename="zgw-zaaktype-export.json"'
)
response[
"Content-Disposition"
] = 'attachment; filename="zgw-zaaktype-export.json"'
return response

def process_file_view(self, request):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ def test_zio_bails_when_info_object_not_visible_because_confidentiality(
self, m, mock_handle: Mock
):
data = MockAPIData()
data.informatie_object["vertrouwelijkheidaanduiding"] = (
VertrouwelijkheidsAanduidingen.geheim
)
data.informatie_object[
"vertrouwelijkheidaanduiding"
] = VertrouwelijkheidsAanduidingen.geheim
data.install_mocks(m)

handle_zaken_notification(data.zio_notification)
Expand Down
3 changes: 2 additions & 1 deletion src/open_inwoner/openzaak/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class UniformCase(Protocol):
"""

@property
def identification(self) -> str: ...
def identification(self) -> str:
...

def process_data(self) -> dict:
"""
Expand Down
6 changes: 3 additions & 3 deletions src/open_inwoner/pdc/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ def filter_by_zaken(self, cases: list[Zaak]):
or months_since_last_zaak_per_zaaktype[zaaktype_identificatie]
> duration_since_start.months
):
months_since_last_zaak_per_zaaktype[zaaktype_identificatie] = (
duration_since_start.months
)
months_since_last_zaak_per_zaaktype[
zaaktype_identificatie
] = duration_since_start.months

zaaktype_ids = list(months_since_last_zaak_per_zaaktype.keys())

Expand Down
3 changes: 2 additions & 1 deletion src/open_inwoner/utils/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@


class ParsePhoneNumber(Protocol):
def __call__(self, value: str) -> "PhoneNumber": ... # pragma: nocover
def __call__(self, value: str) -> "PhoneNumber":
... # pragma: nocover


@deconstructible
Expand Down

0 comments on commit d51dce7

Please sign in to comment.