Skip to content

Commit a14d8b9

Browse files
committed
Hooks
1 parent f03dffd commit a14d8b9

File tree

12 files changed

+52
-43
lines changed

12 files changed

+52
-43
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
exclude: ".yarn/|yarn.lock"
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.4.0
4+
rev: v4.5.0
55
hooks:
66
- id: check-added-large-files
77
- id: check-builtin-literals
@@ -24,24 +24,17 @@ repos:
2424
language: system
2525
always_run: true
2626
- repo: https://github.com/adamchainz/django-upgrade
27-
rev: 1.14.1
27+
rev: 1.15.0
2828
hooks:
2929
- id: django-upgrade
3030
args: [--target-version, "4.2"]
31-
- repo: https://github.com/MarcoGorelli/absolufy-imports
32-
rev: v0.3.1
33-
hooks:
34-
- id: absolufy-imports
35-
- repo: https://github.com/charliermarsh/ruff-pre-commit
36-
rev: "v0.0.290"
31+
- repo: https://github.com/astral-sh/ruff-pre-commit
32+
rev: "v0.1.2"
3733
hooks:
3834
- id: ruff
39-
- repo: https://github.com/psf/black
40-
rev: 23.9.1
41-
hooks:
42-
- id: black
35+
- id: ruff-format
4336
- repo: https://github.com/pre-commit/mirrors-eslint
44-
rev: v8.49.0
37+
rev: v8.52.0
4538
hooks:
4639
- id: eslint
4740
args: [--fix]
@@ -70,10 +63,10 @@ repos:
7063
args: [--list-different, --no-semi]
7164
exclude: "^conf/|.*\\.html$|.*\\.json$"
7265
- repo: https://github.com/tox-dev/pyproject-fmt
73-
rev: 1.1.0
66+
rev: 1.2.0
7467
hooks:
7568
- id: pyproject-fmt
7669
- repo: https://github.com/abravalheri/validate-pyproject
77-
rev: v0.14
70+
rev: v0.15
7871
hooks:
7972
- id: validate-pyproject

pyproject.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ extend-select = [
3434
"SLOT",
3535
# flake8-simplify
3636
"SIM",
37+
# flake8-tidy-imports
38+
"TID",
3739
# flake8-gettext
3840
"INT",
3941
# flake8-use-pathlib
@@ -81,9 +83,14 @@ max-complexity = 15
8183
# No boolean trap in function definitions in the fabfile
8284
"FBT002",
8385
]
84-
# Allow Python files in conf/ and scripts/ without __init__
85-
"conf/*" = ["INP"]
86-
"scripts/*" = ["INP"]
86+
"conf/*" = [
87+
# Allow Python files in conf/ without __init__
88+
"INP",
89+
]
90+
"scripts/*" = [
91+
# Allow Python files in scripts/ without __init__
92+
"INP",
93+
]
8794

8895
[tool.coverage.run]
8996
branch = true

webpack.library.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = (PRODUCTION) => {
5151
presets: [
5252
[
5353
"@babel/preset-env",
54-
{ useBuiltIns: "usage", corejs: "3.25", targets: "defaults" },
54+
{ useBuiltIns: "usage", corejs: "3.33", targets: "defaults" },
5555
],
5656
],
5757
plugins: plugins || [],
@@ -208,6 +208,18 @@ module.exports = (PRODUCTION) => {
208208
],
209209
})
210210
},
211+
resolvePreactAsReact() {
212+
return {
213+
resolve: {
214+
alias: {
215+
react: "preact/compat",
216+
"react-dom/test-utils": "preact/test-utils",
217+
"react-dom": "preact/compat", // Must be below test-utils
218+
"react/jsx-runtime": "preact/jsx-runtime",
219+
},
220+
},
221+
}
222+
},
211223
babelWithReactRule() {
212224
return babelRule({
213225
presets: [["@babel/preset-react", { runtime: "automatic" }]],

workbench/accounts/tasks.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ def generate_pairings(users):
3030

3131
while randomized:
3232
if len(randomized) == 3:
33-
yield randomized, [
34-
tuple(sorted((randomized[0].id, randomized[1].id))),
35-
tuple(sorted((randomized[0].id, randomized[2].id))),
36-
tuple(sorted((randomized[1].id, randomized[2].id))),
37-
]
33+
yield (
34+
randomized,
35+
[
36+
tuple(sorted((randomized[0].id, randomized[1].id))),
37+
tuple(sorted((randomized[0].id, randomized[2].id))),
38+
tuple(sorted((randomized[1].id, randomized[2].id))),
39+
],
40+
)
3841
break
3942

4043
else:

workbench/deals/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def __init__(self, *args, **kwargs):
344344
instance.status = int(kwargs["request"].GET.get("status", instance.status))
345345
if instance.status in {Deal.ACCEPTED, Deal.DECLINED}:
346346
instance.closed_on = dt.date.today()
347-
elif instance.status in {Deal.OPEN}:
347+
elif instance.status == Deal.OPEN:
348348
instance.closed_on = None
349349
instance.closing_type = None
350350
instance.closing_notice = ""

workbench/logbook/test_logbook.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ def test_log_and_create_service(self):
197197
)
198198
self.assertContains(
199199
response,
200-
'<a href="{}#service{}">service title: service description'
201-
"</a>".format(project.get_absolute_url(), entry.service.id),
200+
'<a href="{}#service{}">service title: service description' "</a>".format(
201+
project.get_absolute_url(), entry.service.id
202+
),
202203
)
203204

204205
def test_log_and_create_service_with_flat_rate(self):

workbench/planning/reporting.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime as dt
22
from collections import defaultdict
3-
from itertools import islice, takewhile
3+
from itertools import islice, starmap, takewhile
44

55
from django.db import connections
66
from django.db.models import Q, Sum
@@ -371,10 +371,7 @@ def _project_record(self, project, offers):
371371
sorted(
372372
filter(
373373
None,
374-
(
375-
self._offer_record(offer, work_list)
376-
for offer, work_list in sorted(offers.items())
377-
),
374+
starmap(self._offer_record, sorted(offers.items())),
378375
),
379376
key=lambda row: (
380377
row["offer"]["date_from"],
@@ -579,10 +576,7 @@ def report(self):
579576
"projects_offers": sorted(
580577
filter(
581578
None,
582-
(
583-
self._project_record(project, offers)
584-
for project, offers in self._projects_offers.items()
585-
),
579+
starmap(self._project_record, self._projects_offers.items()),
586580
),
587581
key=lambda row: (
588582
row["project"]["date_from"],

workbench/projects/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def __init__(self, *args, **kwargs):
451451
offer = self.instance.offer
452452
if offer and offer.status > offer.SERVICE_GROUP:
453453
for field in self.fields:
454-
if field not in {"allow_logging"}:
454+
if field != "allow_logging":
455455
self.fields[field].disabled = True
456456

457457
if self.request.method == "GET":

workbench/projects/reporting.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from collections import defaultdict
2+
from itertools import starmap
23
from types import SimpleNamespace
34

45
from django.db.models import Sum
@@ -127,7 +128,7 @@ def _user(u, row):
127128
"url": _logbook_url(rendered_by=u.id),
128129
}
129130

130-
users = [_user(u, row) for u, row in sorted(hours.items())]
131+
users = list(starmap(_user, sorted(hours.items())))
131132

132133
return {
133134
"types": [external_type, *internal_types],

workbench/templatetags/workbench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def field_value_pairs(object, fields=None):
7070
or field.one_to_one
7171
or field.many_to_many
7272
or field.primary_key
73-
or field.name in {"_fts"}
73+
or field.name == "_fts"
7474
or field.name not in fields
7575
):
7676
continue

workbench/tools/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def querystring(params=None, **kwargs):
254254
sorted(
255255
(key, value)
256256
for key, value in dict(params, **kwargs).items()
257-
if key not in {"error"} and value
257+
if key != "error" and value
258258
)
259259
)
260260
return "?%s" % query

workbench/tools/search.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ def fts(table, fields):
6565
DROP TRIGGER IF EXISTS {table}_fts_trigger ON {table};
6666
CREATE TRIGGER {table}_fts_trigger BEFORE INSERT OR UPDATE
6767
ON {table} FOR EACH ROW EXECUTE PROCEDURE {table}_fts();
68-
""".format(
69-
table=table, fields=", ".join(f"new.{field}" for field in fields)
70-
)
68+
""".format(table=table, fields=", ".join(f"new.{field}" for field in fields))
7169

7270

7371
def process_query(s):

0 commit comments

Comments
 (0)