-
Notifications
You must be signed in to change notification settings - Fork 7
/
pyproject.toml
449 lines (415 loc) · 13.8 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
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
[tool.poetry]
name = "Tilavarauspalvelu"
version = "0"
description = "Backend for the new space and resource reservation platform for the City of Helsinki."
authors = []
classifiers = [
# This prevents accidentally running 'poetry publish'
"Private :: Do Not Upload",
]
[tool.poetry.dependencies]
python = ">=3.13,<3.14"
Django = "5.1.4"
django-auditlog = "3.0.0"
django-cors-headers = "4.6.0"
django-environment-config = { version = "0.2.2", extras = ["db"] }
django-filter = "24.3"
django-health-check = "3.18.3"
django-helusers = "0.13.0"
django-jinja = "2.11.0"
django-lookup-property = "0.1.7"
django-modeltranslation = "0.19.11"
django-mptt = "0.16.0"
django-redis = "5.4.0"
djangorestframework = "3.15.2"
easy-thumbnails = "2.10"
graphene-django = "3.2.2"
graphene-django-extensions = "0.4.9"
helsinki-profile-gdpr-api = "0.2.0"
icalendar = "6.1.0"
mjml-python = "1.3.4"
psycopg2 = "2.9.10"
python-dateutil = "2.9.0.post0"
redis = { version = "5.2.1", extras = ["hiredis"] }
sentry-sdk = "2.19.2"
social-auth-app-django = "5.4.2"
# Skip installation on Windows as uWSGI does not support it without Cygwin.
uWSGI = { version = "2.0.28", markers = "sys_platform != 'win32'" }
whitenoise = "6.8.2"
xhtml2pdf = "0.2.16"
[tool.poetry.group.admin.dependencies]
# Dependencies related to the admin panel or other "administrative" tasks.
django-admin-data-views = "0.4.3"
django-admin-extra-buttons = "1.6.0"
django-admin-rangefilter = "0.13.2"
django-admin-sortable2 = "2.2.4"
django-extensions = "3.2.3"
django-import-export = "4.3.3"
django-more-admin-filters = "1.9"
django-subforms = "0.3.1"
django-tinymce = "4.1.0"
[tool.poetry.group.celery.dependencies]
# Dependencies related to Celery tasks.
celery = { version = "5.4.0", extras = ["redis"] }
django-celery-beat = "2.7.0"
django-celery-results = "2.5.1"
[tool.poetry.group.test.dependencies]
# Dependencies only required for running tests.
django-debug-toolbar = "4.4.5" # Can't be updated past 4.4.5 until django-graphiql-debug-toolbar is updated
django-graphiql-debug-toolbar = "0.2.0"
factory-boy = "3.3.1"
faker = "33.1.0"
freezegun = "1.5.1"
html2text = "2024.2.26"
polib = "1.2.0"
pyinstrument = "5.0.0"
pypdf2 = "3.0.1"
pytest = "8.3.4"
pytest-cov = "6.0.0"
pytest-django = "4.9.0"
pytest-xdist = "3.6.1"
[tool.poetry.group.lint.dependencies]
# Dependencies only required for linting.
pre-commit = "4.0.1"
ruff = "0.8.4"
ruff-lsp = "0.0.59"
[tool.poetry.plugins.pytest11]
tilavarauspalvelu = "tests.plugins"
[tool.ruff]
fix = true
unsafe-fixes = true
line-length = 120
target-version = "py313"
extend-exclude = [
"build",
"local_settings.py",
"migrations",
"config/settings.py",
"venv",
]
[tool.ruff.format]
# Enable reformatting of code snippets in docstrings.
docstring-code-format = true
preview = true
[tool.ruff.lint]
explicit-preview-rules = true
preview = true
select = [
"A", # flake8-builtins
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
"COM", # flake8-commas
"D200", # pydocstyle: One-line docstring should fit on one line
"D201", # pydocstyle: No blank lines allowed before function docstring (found {num_lines})
"D202", # pydocstyle: No blank lines allowed after function docstring (found {num_lines})
"D209", # pydocstyle: Multi-line docstring closing quotes should be on a separate line
"D213", # pydocstyle: Multi-line docstring summary should start at the second line
"DJ", # flake8-django
#"DTZ", # flake8-datetimez # TODO: Enable this and fix (52) issues
"E", # pycodestyle errors
"EM", # flake8-errmsg
"ERA", # eradicate
"F", # pyflakes
"FA", # flake8-future-annotations
"FBT", # flake8-boolean-trap
"FLY", # flynt
"FURB", # refurb
"I", # isort
"ICN", # flake8-import-conventions
"INP", # flake8-no-pep420
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
"LOG", # flake8-logging
"N", # pep8-naming
"PERF", # Perflint
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"PYI", # flake8-pyi
"Q", # flake8-quotes
"R", # Refactor
"RET", # flake8-return
"RSE", # flake8-raise
"RUF", # ruff-specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"SLF", # flake8-self
"T20", # flake8-print
"TC", # flake8-type-checking
"TID", # flake8-tidy-imports
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle warnings
]
# Preview rules
extend-select = [
"A006", # builtin-lambda-argument-shadowing
"B901", # return-in-generator
"B909", # loop-iterator-mutation
"C420", # unnecessary-dict-comprehension-for-iterable
"FURB110", # if-exp-instead-of-or-operator
"FURB113", # repeated-append
"FURB118", # reimplemented-operator
"FURB131", # delete-full-slice
"FURB132", # check-and-remove-from-set
"FURB142", # for-loop-set-mutations
"FURB145", # slice-copy
"FURB148", # unnecessary-enumerate
"FURB157", # verbose-decimal-constructor
"FURB171", # single-item-membership-test
"FURB188", # slice-to-remove-prefix-or-suffix
"FURB189", # subclass-builtin
"FURB192", # sorted-min-max
"PLC1901", # compare-to-empty-string
"PLC2701", # import-private-name
"PLC2801", # unnecessary-dunder-call
"PLE1141", # dict-iter-missing-items
"PLE1141", # dict-iter-missing-items
"PLE4703", # modified-iterating-set
"PLR0916", # too-many-boolean-expressions
"PLR0917", # too-many-positional-arguments
"PLR1702", # too-many-nested-blocks
"PLR1733", # unnecessary-dict-index-lookup
"PLR6104", # non-augmented-assignment
"PLR6201", # literal-membership
"PLW0108", # unnecessary-lambda
"PLW1514", # unspecified-encoding
"PLW1641", # eq-without-hash (NOTE: Does not check for __hash__ implementations in superclasses.)
"PLW3201", # bad-dunder-method-name
"RUF027", # missing-f-string-syntax
"RUF028", # invalid-formatter-suppression-comment
"RUF031", # incorrectly-parenthesized-tuple-in-subscript
"RUF032", # decimal-from-float-literal
"RUF033", # post-init-default
"RUF034", # useless-if-else
"RUF035", # unsafe-markup-use
"RUF036", # none-not-at-end-of-union
"UP042", # replace-str-enum
]
ignore = [
# Conflicting with ruff-format
"ISC001", # single-line-implicit-string-concatenation
# Code style preference
"COM812", # missing-trailing-comma
# No need to annotate mutable class variables with `typing.ClassVar`
"RUF012", # mutable-class-default
# Allow longer error messages in raised exceptions
"TRY003", # raise-vanilla-args
# Any-typing allowed
"ANN401", # any-type
# Allow empty comments. We use emtpy comments for forcing better code formatting.
"PLR2044", # empty-comment
# To be enabled in the future
"PLW2901", # redefined-loop-name
]
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$|^options$|^info$|^name$|^obj$|^request$|^user|^view$|^input_data$|^filters$"
task-tags = ["TODO", "FIXME", "XXX", "type"]
[tool.ruff.lint.extend-per-file-ignores]
"local_settings*.py" = [
"ERA001", # Commented code is fine here.
]
"tilavarauspalvelu/migrations/*.py" = [
"ANN", # No need to annotate migrations
"ARG", # Allow unused arguments allowed in migrations
]
"config/settings.py" = [
"ANN", # No need to annotate settings
"ARG", # Allow unused arguments allowed in settings
]
"utils/date_utils.py" = [
"PLR0917", # Can have as many positional arguments as needed.
"TID251" # Can use banned imports here (e.g. datetime.datetime.now)
]
"tilavarauspalvelu/management/commands/data_creation/*.py" = [
"PLR0913", # Can take as many arguments as needed.
"PLR0915", # Can have as many statements as needed.
"PLR0917", # Can have as many positional arguments as needed.
"S101", # Asserts are fine in test data creation.
"S311", # pseudo-random generators are fine here.
]
"tilavarauspalvelu/api/webhooks/serializers.py" = [
"N802", # Allow non-lowercase function names for webhook serializers.
"N815", # Allow mixedCase variables for webhook serializers.
]
"tilavarauspalvelu/api/graphql/extensions/error_codes.py" = [
"ERA001", # Commented code is fine here.
]
"tilavarauspalvelu/api/graphql/types/*/filtersets.py" = [
"FBT001", # Filtersets filter_* methods require three positional arguments, last one being boolean.
]
"tests/*.py" = [
"ANN", # No need to annotate tests
"ARG", # Allow unused arguments in tests (These are usually fixtures)
"FBT001", # Factory methods may require positional boolean arguments
"N801", # Allow whatever class names in tests
"N802", # Allow whatever function names in tests
"N806", # Allow whatever variable names in tests
"N815", # Allow whatever variable names in tests
"PLC1901", # Allow comparing to empty strings.
"PLR0915", # Can have as many statements as needed.
"PLR0917", # Allow as many positional arguments as needed in tests
"PLR2004", # Magic value comparisons are allowed in tests.
"S101", # Obviousle asserts are fine in tests
"S105", # Hardcoded passwords are fine in tests
"S106", # Hardcoded passwords are fine in tests
"S108", # No need to care about insecure temp file usages in tests
"S311", # Pseudo-random generators are fine here.
"SLF", # Allow accessing private members in tests
"TID251" # Can use banned imports here (e.g. datetime.datetime.now)
]
"tilavarauspalvelu/api/graphql/types/application_round_time_slot/types.py" = ["I002"] # FIXME Somehow importing `TYPE_CHECKING` to this file causes ImportError for `tilavarauspalvelu.api.graphql.schema.schema`
"local_settings.py" = ["I002"] # missing-required-import
"local_settings_example.py" = ["I002"] # missing-required-import
"manage.py" = ["I002"] # missing-required-import
[tool.ruff.lint.isort]
combine-as-imports = false
split-on-trailing-comma = false
required-imports = ["from __future__ import annotations"]
known-third-party = [
"django",
]
known-first-party = [
"config",
"tilavarauspalvelu",
"utils",
]
section-order = [
"future",
"standard-library",
"third-party",
"first-party",
"testing",
"local-folder",
]
sections.testing = ["tests"]
[tool.ruff.lint.flake8-annotations]
suppress-dummy-args = true
[tool.ruff.lint.flake8-type-checking]
strict = true
quote-annotations = false
exempt-modules = [
"typing",
"ast",
"lookup_property",
"graphql",
"graphene_django",
"graphene_django_extensions",
"tilavarauspalvelu.api.graphql",
]
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"django.core.handlers.wsgi.WSGIRequest".msg = "Use `tilavarauspalvelu.typing.WSGIRequest` instead."
"datetime.datetime.now".msg = "Use `utils.date_utils.local_datetime` instead."
"django.utils.timezone.now".msg = "Use `utils.date_utils.local_datetime` instead."
"django.utils.timezone.get_default_timezone".msg = "Use `utils.date_utils.DEFAULT_TIMEZONE` instead."
"graphene_django_extensions.typing.GQLInfo".msg = "Use `tilavarauspalvelu.typing.GQLInfo` instead."
"query_optimizer.typing.GQLInfo".msg = "Use `tilavarauspalvelu.typing.GQLInfo` instead."
"django.contrib.auth.get_user_model".msg = "Use `tilavarauspalvelu.models.User` instead."
[tool.ruff.lint.flake8-import-conventions]
banned-from = [
# Python standard libraries
"base64",
"csv",
"datetime",
"hashlib",
"hmac",
"json",
"logging",
"math",
"os",
"pickle",
"random",
"re",
"shutil",
"subprocess",
"sys",
"tempfile",
"time",
"uuid",
"xml",
"yaml",
# Project-specific
"error_codes",
]
[tool.ruff.lint.flake8-self]
extend-ignore-names = ["_base_manager", "_default_manager", "_meta", "_mptt_meta", "_defaults", "_errors"]
[tool.ruff.lint.flake8-unused-arguments]
ignore-variadic-names = true
[tool.ruff.lint.flake8-gettext]
extend-function-names = ["pgettext", "pgettext_lazy", "gettext_lazy"]
[tool.ruff.lint.pep8-naming]
classmethod-decorators = [
"classproperty",
"permission",
]
extend-ignore-names = ["root"] # Allow using `root` as the first argument name.
[tool.ruff.lint.pylint]
max-returns = 8
max-positional-args = 5
max-args = 10
max-bool-expr = 6
[tool.ruff.lint.mccabe]
max-complexity = 10
[tool.bandit]
exclude_dirs = [
"tests",
]
skips = [
"B101", # Assert is fine.
"B311", # Random is fine.
]
[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "config.settings"
DJANGO_SETTINGS_ENVIRONMENT = "AutomatedTests"
markers = [
"slow: Marks a test that takes a long time to run.",
]
python_files = [
"tests.py",
"test_*.py",
"*_tests.py",
]
norecursedirs = [
".git",
"venv",
"build",
]
filterwarnings = [
"ignore:.*collections.*:DeprecationWarning:graphene",
"ignore:.*ugettext_lazy.*::recurrence",
"ignore:.*No directory at.*:UserWarning:whitenoise",
"ignore:.*ugettext_lazy.*::auditlog",
"ignore:.*smart_text.*::auditlog",
"ignore:.*ugettext_lazy.*::jsonfield",
]
[tool.coverage.run]
source = [
"allocation/",
"applications/",
"email_notification/",
"merchants/",
"opening_hours/",
"permissions/",
"reservation_units/",
"reservations/",
"resources/",
"services/",
"spaces/",
"terms_of_use/",
"config/",
"users/",
"utils/",
]
[tool.coverage.report]
omit = [
"*migrations*",
"*tests*",
]
exclude_also = [
"if TYPE_CHECKING:",
"def __repr__",
"def __str__",
]