-
Notifications
You must be signed in to change notification settings - Fork 146
/
pyproject.toml
199 lines (165 loc) · 6.79 KB
/
pyproject.toml
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
[tool.poetry]
package-mode = false
name = "evap"
description = "EvaP"
readme = "README.md"
packages = [{include = "evap"}]
[tool.poetry.dependencies]
python = "~3.10.0"
django-extensions = "~3.2.3"
django-fsm = "~2.8.2"
Django = "~5.1.0"
mozilla-django-oidc = "~4.0.1"
openpyxl = "~3.1.5"
psycopg = "~3.2.3"
psycopg-c = { version = "~3.2.3", optional = true }
psycopg-binary = { version = "~3.2.3", optional = true }
redis = "~5.2.0"
typing-extensions = "~4.12.2"
xlwt = "~1.3.0"
[tool.poetry.group.dev.dependencies]
black = "~24.10.0"
coverage = { version = "7.6.4", extras = ["toml"] }
django-debug-toolbar = "~4.4"
django-stubs = "5.1.1"
django-webtest = "~1.9.10"
isort = "~5.13.1"
model-bakery = "~1.20.0"
mypy = "~1.13.0"
openpyxl-stubs = "~0.1.25"
pylint-django = "~2.6.1"
pylint = "~3.3.0"
ruff = "~0.7.0"
tblib = "~3.0.0"
xlrd = "~2.0.1"
typeguard = "~4.4.0"
[tool.poetry.extras]
psycopg-c = ["psycopg-c"]
psycopg-binary = ["psycopg-binary"]
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
##############################################
[tool.black]
line-length = 120
include = '(evap|tools).*\.pyi?$'
extend-exclude = """\
.*/urls\\.py|\
.*/migrations/.*\
"""
##############################################
[tool.isort]
profile = "black"
src_paths = ["evap", "tools"]
line_length = 120
skip_gitignore = true
extend_skip_glob = ["**/migrations/*"]
##############################################
[tool.ruff]
target-version = "py310"
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"]
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", # 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
"deployment/*.py" = ["INP001"] # not intended for direct import
[tool.ruff.format]
exclude = ["**/urls.py", "**/migrations/*.py"]
##############################################
[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]+$)"
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", "setUpTestData", "setUp", "tearDown"]
[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", "too-many-arguments",
"too-many-statements", "too-many-return-statements", "too-many-branches", "unnecessary-lambda-assignment",
"global-statement",
]
[tool.pylint.design]
max-positional-arguments = 7
##############################################
[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"]
exclude = 'evap/.*/migrations/.*\.py$'
[tool.django-stubs]
django_settings_module = "evap.settings"
[[tool.mypy.overrides]]
module = [
"django_fsm.*",
"django_sendfile.*",
"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"