Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
310 lines (276 loc) · 12.4 KB
/
Copy pathpyproject.toml
File metadata and controls
310 lines (276 loc) · 12.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
[project]
name = "evap"
description = "EvaP"
version = "2026.5.0"
readme = "README.md"
requires-python = ">=3.13.0"
dependencies = [
"django-extensions~=4.1.0",
"django-fsm-2~=4.2.4",
"Django~=6.0.2",
"mozilla-django-oidc~=5.0.2",
"openpyxl~=3.1.5",
"psycopg~=3.3.2",
"pydantic~=2.13.3",
"redis~=8.1.0",
"requests~=2.34.2",
"typing-extensions~=4.16.0",
"xlwt~=1.3.0",
]
[project.optional-dependencies]
psycopg-binary = ["psycopg[binary]"]
psycopg-c = ["psycopg[c]"]
[dependency-groups]
dev = [
"coverage~=7.15.0",
"django-debug-toolbar~=7.0",
"django-stubs~=6.0.2",
"django-webtest~=1.9.13",
"djangofmt~=1.0",
"model-bakery~=1.24.0",
"mypy~=2.3.0",
"openpyxl-stubs~=0.1.25",
"pylint-django~=2.8.0",
"pylint~=4.0.4",
"ruff~=0.16.1",
"tblib~=3.2.2",
"types-requests~=2.33.0",
"xlrd~=2.0.1",
"typeguard~=4.6.0",
"selenium~=4.46.0",
]
lsp = [
"python-lsp-server",
"pylsp-rope",
"python-lsp-ruff",
"pylsp-mypy",
]
[tool.uv]
no-binary-package = [
"psycopg-c",
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build]
skip-excluded-dirs = false # otherwise, the artifacts below will be skipped
exclude = [
"evap/static/bootstrap",
"evap/static/font-awesome",
]
artifacts = [
"evap/static/css/evap.css",
"evap/static/css/evap.css.map",
"evap/static/js/*.js",
"evap/static/js/*.map",
"evap/static/bootstrap/dist/js/bootstrap.bundle.min.js",
"evap/static/bootstrap/dist/js/bootstrap.bundle.min.js.map",
"evap/static/font-awesome/webfonts/",
"evap/locale/**/*.mo",
]
##############################################
[tool.ruff]
line-length = 120
[tool.ruff.lint]
# Those are interesting, but not yet addressed: PYI,Q,SIM,PTH,TRY,RUF
select = ["F", "E", "B", "W", "N", "UP", "YTT", "FIX", "ASYNC", "A", "DJ", "EXE", "ICN", "G", "SLOT", "TID", "TCH", "INT", "C4", "ISC", "INP", "PIE", "RSE", "RET", "COM","PGH","FLY", "PERF", "PL", "BLE", "I", "INP", "TID252"]
ignore = [
"E501", # line-too-long: black does code formatting for us
"FIX004", # hacks should be possible
"A003", # we shadow some builtins sometime
"DJ008", # do not use __str__ where it is not required
"COM812", # incompatible with formatter
"N802", # not as mighty as pylint's invalid-name https://github.com/astral-sh/ruff/issues/7660
"PLR0913", "PLR0917", # we can't determine a good limit for arguments. reviews should spot bad cases of this.
"PLR2004", "PLW2901",
]
pep8-naming.extend-ignore-names = ["assert*", "*Formset"] # custom assert methods use camelCase; Formsets use PascalCase
[tool.ruff.lint.per-file-ignores]
"**/migrations/*.py" = ["N806"] # migrations have model classes as local variables, we use PascalCase for these
[tool.ruff.format]
exclude = ["**/urls.py"]
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"evap.settings".msg = "Use django.conf.settings instead."
##############################################
[tool.djangofmt]
extend-exclude = ["evap/static/bootstrap"]
html-void-self-closing = "unchanged"
custom-blocks = ["breadcrumb_item", "breadcrumb_item_url"]
##############################################
[tool.pylint.master]
jobs = 0
load-plugins = ["pylint_django"]
django-settings-module = "evap.settings"
[tool.pylint.basic]
# For most code: snake_case, or PascalCaseFormset, because django does it that way.
# see https://docs.djangoproject.com/en/4.0/topics/forms/formsets/
# For migrations, models are assigned as local variables. Until pylint supports configuration-per-directory, we also
# need to allow that here (their issue 618)
variable-rgx = "(^[a-z0-9_]+$)|(^[A-Za-z]+$)|(^[A-Z_]+$)"
argument-rgx = "(^[a-z0-9_]+$)|(^[A-Za-z]+$)"
method-rgx = "(^[a-z0-9_]+$)|(^assert[A-Za-z]+$)"
# Allow 4 leading digits for migrations
module-rgx = "^([0-9]{4})?([a-z_][a-z0-9_]+)$"
good-names = [ "i", "j", "k", "ex", "Run", "_", "__", "e", "logger", "setUpClass", "setUpTestData", "setUp", "tearDown", "do_not_call_in_templates" ]
[tool.pylint.format]
expected-line-ending-format = "LF"
[tool.pylint.messages_control]
enable = ["all"]
disable = [
"locally-disabled", # we allow locally disabling some checks if we think it makes sense to do that.
"suppressed-message",
"ungrouped-imports", # isort
"wrong-import-order", # isort
"too-many-public-methods", # reported for some models, that won't change
"too-few-public-methods", # noisy, e.g. exception classes, mixins etc
"no-member", # false positives, deals badly with django classes
"logging-format-interpolation", # decided against the proposed change in favor of .format()
"too-many-ancestors", # noisy, reported for all test classes
"missing-docstring", # yeah... we don't have those
"protected-access", # for us that means "be careful", not "don't do it"
"too-many-lines", # we don't currently think that splitting up views.py or test_views.py creates any value
"duplicate-code", # Mostly imports and test setup.
"cyclic-import", # We use these inside methods that require models from multiple apps. Tests will catch actual errors.
"unsupported-binary-operation", # broken in pylint: https://github.com/PyCQA/pylint/issues/7381
"use-implicit-booleaness-not-comparison-to-string", # forces us to use less expressive code
"use-implicit-booleaness-not-comparison-to-zero", # forces us to use less expressive code
# the following are covered by ruff
"broad-exception-caught", "line-too-long", "unused-wildcard-import", "wildcard-import",
"unnecessary-lambda-assignment",
"wrong-import-position",
# Obtained using a script (See: https://github.com/e-valuation/EvaP/pull/2767)
# Very similar to the list (https://docs.astral.sh/ruff/default-rules/#pylint-pl) mapped to pylint names for the codes.
"typevar-name-incorrect-variance", # C0105
"typevar-double-variance", # C0131
"typevar-name-mismatch", # C0132
"single-string-used-for-slots", # C0205
"consider-using-dict-items", # C0206
"use-maxsplit-arg", # C0207
"use-sequence-for-iteration", # C0208
"useless-import-alias", # C0414
"import-outside-toplevel", # C0415
"use-implicit-booleaness-not-len", # C1802
"non-ascii-name", # C2401
"non-ascii-module-import", # C2403
"unnecessary-direct-lambda-call", # C3002
"init-is-generator", # E0100
"return-in-init", # E0101
"nonlocal-and-global", # E0115
"nonlocal-without-binding", # E0117
"used-prior-global-declaration", # E0118
"assigning-non-slot", # E0237
"duplicate-bases", # E0241
"unexpected-special-method-signature", # E0302
"invalid-length-returned", # E0303
"invalid-bool-returned", # E0304
"invalid-index-returned", # E0305
"invalid-str-returned", # E0307
"invalid-bytes-returned", # E0308
"invalid-hash-returned", # E0309
"invalid-all-object", # E0604
"invalid-all-format", # E0605
"potential-index-error", # E0643
"misplaced-bare-raise", # E0704
"repeated-keyword", # E1132
"await-outside-async", # E1142
"logging-too-many-args", # E1205
"logging-too-few-args", # E1206
"bad-format-character", # E1300
"bad-string-format-type", # E1307
"bad-str-strip-call", # E1310
"invalid-envvar-value", # E1507
"singledispatch-method", # E1519
"singledispatchmethod-function", # E1520
"yield-inside-async-function", # E1700
"bidirectional-unicode", # E2502
"invalid-character-backspace", # E2510
"invalid-character-sub", # E2512
"invalid-character-esc", # E2513
"invalid-character-nul", # E2514
"invalid-character-zero-width-space", # E2515
"comparison-with-itself", # R0124
"comparison-of-constants", # R0133
"property-with-parameters", # R0206
"consider-using-from-import", # R0402
"too-many-return-statements", # R0911
"too-many-branches", # R0912
"too-many-arguments", # R0913
"too-many-statements", # R0915
"too-many-positional-arguments", # R0917
"redefined-argument-from-local", # R1704
"stop-iteration-return", # R1708
"useless-return", # R1711
"consider-using-in", # R1714
"chained-comparison", # R1716
"consider-using-sys-exit", # R1722
"consider-using-min-builtin", # R1730
"unnecessary-dict-index-lookup", # R1733
"unnecessary-list-index-lookup", # R1736
"unnecessary-lambda", # W0108
"useless-else-on-loop", # W0120
"self-assigning-variable", # W0127
"redeclared-assigned-name", # W0128
"assert-on-string-literal", # W0129
"named-expr-without-context", # W0131
"pointless-exception-statement", # W0133
"nan-comparison", # W0177
"bad-staticmethod-argument", # W0211
"super-without-brackets", # W0245
"import-self", # W0406
"global-variable-not-assigned", # W0602
"global-statement", # W0603
"global-at-module-level", # W0604
"self-cls-assignment", # W0642
"binary-op-exception", # W0711
"bad-open-mode", # W1501
"shallow-copy-environ", # W1507
"invalid-envvar-default", # W1508
"subprocess-popen-preexec-fn", # W1509
"subprocess-run-check", # W1510
"useless-with-lock", # W2101
"nested-min-max", # W3301
]
##############################################
[tool.coverage.run]
branch = true
omit = ["*migrations*", "*__init__.py"]
source = ["evap", "tools"]
[tool.coverage.report]
omit = ["*/migrations/*", "*__init__.py"]
exclude_also = [
# mypy asserts these cases are not possible
'\n.*assert_never\(.*\)', # \n excludes previous line, see https://coverage.readthedocs.io/en/latest/excluding.html#multi-line-exclusion-regexes
]
##############################################
[tool.mypy]
packages = ["evap", "tools"]
plugins = ["mypy_django_plugin.main"]
# list from https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options
warn_unused_configs = true
warn_redundant_casts = true
warn_unused_ignores = true
strict_equality = true
[tool.django-stubs]
django_settings_module = "evap.settings"
[[tool.mypy.overrides]]
module = [
"django_fsm.*",
"django_webtest.*",
"debug_toolbar.*",
"mozilla_django_oidc.*",
"model_bakery.*",
"webtest.*",
"xlrd.*",
"xlwt.*",
"evap.staff.fixtures.*",
]
ignore_missing_imports = true
##############################################
[tool.pytest.ini_options]
# We don't officially use pytest, but last time we wanted to, this worked for us with pytest-django
# pytest-xdist worked for parallelizing tests.
DJANGO_SETTINGS_MODULE = "evap.settings"
python_files = ["tests.py", "test_*.py", "*_tests.py"]
testpaths = ["evap", "tools"]
norecursedirs=["locale", "logs", "static", "static_collected", "upload"]
addopts = "--reuse-db"