Skip to content

Commit b906fc3

Browse files
committed
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! [WIP] pre-commit and ruff
1 parent 44cdbf7 commit b906fc3

12 files changed

+23
-40
lines changed

.pre-commit-config.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ repos:
1515
# Run the linter.
1616
- id: ruff
1717
args: [--fix]
18+
types: [file, python]
1819
# Run the formatter.
1920
# - id: ruff-format
2021
- repo: https://github.com/pycqa/flake8
@@ -26,3 +27,4 @@ repos:
2627
hooks:
2728
- id: black
2829
language_version: python3.11
30+
types: [file, python]

ruff.toml

+4-30
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ exclude = [
2626
"node_modules",
2727
"site-packages",
2828
"venv",
29+
"env",
2930
]
3031

3132
# Same as Black.
@@ -37,12 +38,12 @@ target-version = "py311"
3738

3839
[lint]
3940
select = [
40-
# https://docs.astral.sh/ruff/rules/#pyflakes-f
41+
# https://docs.astral.sh/ruff/rules/#error-e
4142
"E",
4243
# https://docs.astral.sh/ruff/rules/#pyflakes-f
4344
"F",
44-
# https://docs.astral.sh/ruff/rules/#isort-i
45-
"I",
45+
# Bugbear
46+
"B",
4647
]
4748
ignore = [
4849
# Whitespace before ':' (conflicts with Black)
@@ -72,30 +73,3 @@ unfixable = []
7273

7374
# Allow unused variables when underscore-prefixed.
7475
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
75-
76-
[format]
77-
# Like Black, use double quotes for strings.
78-
quote-style = "double"
79-
80-
# Like Black, indent with spaces, rather than tabs.
81-
indent-style = "space"
82-
83-
# Like Black, respect magic trailing commas.
84-
skip-magic-trailing-comma = false
85-
86-
# Like Black, automatically detect the appropriate line ending.
87-
line-ending = "auto"
88-
89-
# Enable auto-formatting of code examples in docstrings. Markdown,
90-
# reStructuredText code/literal blocks and doctests are all supported.
91-
#
92-
# This is currently disabled by default, but it is planned for this
93-
# to be opt-out in the future.
94-
docstring-code-format = false
95-
96-
# Set the line length limit used when formatting code snippets in
97-
# docstrings.
98-
#
99-
# This only has an effect when the `docstring-code-format` setting is
100-
# enabled.
101-
docstring-code-line-length = "dynamic"

src/open_inwoner/accounts/tests/test_notify_expiring_actions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_send_emails_about_expiring_actions(self):
3030

3131
email1, email2 = mail.outbox
3232

33-
for email, recipient in zip([email1, email2], [joe, schmoe]):
33+
for email, recipient in zip([email1, email2], [joe, schmoe], strict=False):
3434
self.assertEqual(
3535
email.subject, "Acties verlopen vandaag op Open Inwoner Platform"
3636
)

src/open_inwoner/cms/cases/views/services.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def resolve_case(self, case: Zaak, group: ZGWApiGroupConfig) -> Zaak:
265265
):
266266
try:
267267
update_case = task.result()
268-
if hasattr(update_case, "__call__"):
268+
if callable(update_case):
269269
update_case(case)
270270
except BaseException:
271271
logger.exception("Error in resolving case", stack_info=True)

src/open_inwoner/cms/cases/views/status.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,9 @@ def get_case_document_files(
663663

664664
config = OpenZaakConfig.get_solo()
665665
documents = []
666-
for case_info_obj, info_obj in zip(case_info_objects, info_objects):
666+
for case_info_obj, info_obj in zip(
667+
case_info_objects, info_objects, strict=False
668+
):
667669
if not info_obj:
668670
continue
669671
if not is_info_object_visible(

src/open_inwoner/openzaak/import_export.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def __iter__(self) -> Generator[QuerySet, Any, None]:
183183
)
184184

185185
def __eq__(self, other: QuerySet) -> bool:
186-
for a, b in zip(self, other):
186+
for a, b in zip(self, other, strict=False):
187187
if a.difference(b).exists():
188188
return False
189189
return True

src/open_inwoner/openzaak/tests/test_case_detail.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ def test_status_is_retrieved_when_user_logged_in_via_digid(
10301030
links = doc.find(".contactmomenten__link")
10311031

10321032
self.assertEqual(len(links), 3)
1033-
for link, question in zip(links, case["questions"]):
1033+
for link, question in zip(links, case["questions"], strict=False):
10341034
self.assertEqual(
10351035
link.attrib["href"],
10361036
reverse(
@@ -1152,7 +1152,7 @@ def test_pass_endstatus_type_data_if_endstatus_not_reached(
11521152

11531153
self.assertEqual(len(links), 4)
11541154

1155-
for link, question in zip(links, case["questions"]):
1155+
for link, question in zip(links, case["questions"], strict=False):
11561156
self.assertEqual(
11571157
link.attrib["href"],
11581158
reverse(

src/open_inwoner/openzaak/tests/test_import_export.py

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def test_only_models_related_to_exported_catalogus_config_are_included(self):
137137
"ztc_resultaat",
138138
"ztiotc",
139139
),
140+
strict=False,
140141
):
141142
with self.subTest(
142143
f"{mock_field} should not be in the export's {export_field} field"

src/open_inwoner/openzaak/tests/test_zgw_imports.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def test_import_zaaktype_configs_with_catalogs(self, m):
218218
)
219219

220220
# check we linked correctly
221-
for i, root in zip((0, 2), self.roots):
221+
for i, root in zip((0, 2), self.roots, strict=False):
222222
self.assertEqual(res[i + 0].catalogus, cat_configs[root]["AAA"])
223223
self.assertEqual(res[i + 1].catalogus, cat_configs[root]["BBB"])
224224

src/open_inwoner/openzaak/tests/test_zgw_imports_iotypes.py

+2
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ def test_import_zaaktype_informatieobjecttype_configs_with_catalog(self, m):
318318
for root, root_offset in zip(
319319
self.roots,
320320
(0, 2),
321+
strict=False,
321322
):
322323
# first ZaakTypeConfig has two ZaakTypes and two InfoObjectTypes
323324
ztc, ztiotcs = res[root_offset]
@@ -419,6 +420,7 @@ def test_import_zaaktype_informatieobjecttype_configs_with_catalog(self, m):
419420
for root, root_offset in zip(
420421
self.roots,
421422
(0, 1),
423+
strict=False,
422424
):
423425
self.assertEqual(
424426
catalog_and_zaak_type[root][

src/open_inwoner/utils/decorators.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,16 @@ def decorator(func: Callable[..., RT]) -> Callable[..., RT]:
8080

8181
if argspec.defaults:
8282
positional_count = len(argspec.args) - len(argspec.defaults)
83-
defaults = dict(zip(argspec.args[positional_count:], argspec.defaults))
83+
defaults = dict(
84+
zip(argspec.args[positional_count:], argspec.defaults, strict=False)
85+
)
8486
else:
8587
defaults = {}
8688

8789
@wraps(func)
8890
def wrapped(*args, **kwargs) -> RT:
8991
key_kwargs = defaults.copy()
90-
named_args = dict(zip(argspec.args, args), **kwargs)
92+
named_args = dict(zip(argspec.args, args, strict=False), **kwargs)
9193
key_kwargs.update(**named_args)
9294

9395
if argspec.varkw:

src/openklant2/factories/helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def decorator(cls: type[factory.Factory]):
1111
def validate(obj, *args, **kwargs):
1212
validator.validate_python(obj)
1313

14-
setattr(cls, "post_generation_validator", validate)
14+
cls.post_generation_validator = validate
1515

1616
return cls
1717

0 commit comments

Comments
 (0)