Skip to content

Commit bdfcd3f

Browse files
committed
🏷️ [#614] update types
1 parent f2de20d commit bdfcd3f

4 files changed

Lines changed: 12 additions & 16 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,6 @@ ignore = [
115115
"SIM117",
116116
]
117117

118-
119-
[tool.ruff.lint.flake8-tidy-imports.banned-api.logging]
120-
msg = "Use `structlog.stdlib.get_logger(__name__)` instead."
121-
122-
123118
[tool.ruff.lint.isort]
124119
combine-as-imports = true
125120
force-wrap-aliases = false

src/openklant/utils/notifications.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from typing import Dict, List, Union
22

33
from django.db import models, transaction
4-
54
from notifications_api_common.models import NotificationTypes
65
from notifications_api_common.tasks import create_failed_notification, send_notification
76
from notifications_api_common.viewsets import NotificationCreateMixin, NotificationMixin
@@ -18,7 +17,7 @@ def notify(
1817
self,
1918
status_code: int,
2019
data: Union[List, Dict],
21-
instance: models.Model = None,
20+
instance: models.Model | None = None,
2221
**kwargs,
2322
) -> None:
2423
super().notify(status_code, data, instance)
@@ -30,7 +29,7 @@ def _message(self, data, instance=None):
3029

3130
for notif in notifications:
3231
# build the content of the notification
33-
message = self.construct_message(
32+
message = self.construct_message( # type: ignore[reportAttributeAccessIssue]
3433
notif,
3534
instance=instance,
3635
kanaal=config["notifications_kanaal"],
@@ -41,7 +40,7 @@ def _message(self, data, instance=None):
4140
pk = create_failed_notification(message, NotificationTypes.notification)
4241

4342
transaction.on_commit(
44-
lambda msg=message, notification_id=pk: send_notification.delay(
43+
lambda msg=message, notification_id=pk: send_notification.delay( # type: ignore[reportCallIssue]
4544
msg, notification_id
4645
)
4746
)

src/openklant/utils/serializers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
from django.db.models import Model
44
from django.utils.module_loading import import_string
5-
65
from rest_framework.serializers import Serializer
7-
from rest_framework_nested.serializers import NestedHyperlinkedRelatedField
6+
from rest_framework_nested.relations import NestedHyperlinkedRelatedField
87

98

109
# TODO should be moved to vng-api-common once merged/reviewed
@@ -47,7 +46,7 @@ def to_representation(self, value):
4746
serializer.parent = self
4847

4948
if self.default_serializer_kwargs.get("many", False):
50-
value = value.all()
49+
value = value.all() # type: ignore[reportAttributeAccessIssue]
5150

5251
return serializer.to_representation(value)
5352

src/openklant/utils/validators.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import re
2+
13
from django.core.exceptions import ValidationError
24
from django.core.validators import RegexValidator
35
from django.utils.deconstruct import deconstructible
46
from django.utils.encoding import force_str
57
from django.utils.translation import gettext_lazy as _
6-
78
from localflavor.generic.countries.iso_3166 import ISO_3166_1_ALPHA2_COUNTRY_CODES
89

910

@@ -28,7 +29,7 @@ def validate_country(value: str) -> None:
2829
)
2930

3031

31-
def validate_charfield_entry(value, allow_apostrophe=False):
32+
def validate_charfield_entry(value: str, allow_apostrophe=False):
3233
"""
3334
Validates a charfield entry according with Belastingdienst requirements.
3435
@@ -57,6 +58,8 @@ def validate_charfield_entry(value, allow_apostrophe=False):
5758

5859
@deconstructible
5960
class RegexWithDisallowedPrefixesValidator(RegexValidator):
61+
regex: re.Pattern[str]
62+
6063
def __init__(self, *args, **kwargs):
6164
self.disallowed_prefixes = kwargs.pop("disallowed_prefixes")
6265
self.message_disallowed_prefix = kwargs.pop("message_disallowed_prefix")
@@ -99,7 +102,7 @@ def __call__(self, value):
99102
"""
100103
Validates that the input matches the regular expression.
101104
"""
102-
if not self.regex.search(force_str(value)):
105+
if not self.regex.search(force_str(value)): # type: ignore[reportAttributeAccessIssue]
103106
message = "{0}: {1}".format(self.message, force_str(value))
104107
raise ValidationError(message, code=self.code)
105108

@@ -115,7 +118,7 @@ def __call__(self, value):
115118
)
116119

117120
validate_no_space = CustomRegexValidator(
118-
regex="^[\S]+$", message=_("Geen spaties toegestaan")
121+
regex=r"^[\S]+$", message=_("Geen spaties toegestaan")
119122
)
120123

121124
validate_bag_id = CustomRegexValidator(

0 commit comments

Comments
 (0)