-
Notifications
You must be signed in to change notification settings - Fork 8
/
pyproject.toml
167 lines (152 loc) · 4.59 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
[tool.ruff]
# By default ruff also respect gitignore files
# Same as Black.
line-length = 88
indent-width = 4
target-version = "py311"
[tool.ruff.lint]
# Enable Pyflakes (`F`), pycodestyle (`E`, `W`), isort (`I`), pep8-naming (`N`), flake8-bugbear (`B`)
# T201: check for prints, C90: mccabe complexity
select = [
"F",
"E",
"W",
"C90",
"I",
"UP",
"ASYNC",
"S",
"B",
"A",
"COM",
"C4",
"DTZ",
"FA",
"ISC",
"ICN",
"INP",
"PIE",
"T20",
"PYI",
"PT",
"Q",
"SLF",
"SLOT",
"SIM",
"TCH",
"PTH",
"PL",
"TRY",
"FLY",
"PERF",
"FURB",
"RUF",
] # "B", "N" to add later
# We may want to enable "ERA" to found commented-out code
ignore = [
"E203",
"E266",
"E501",
"F403",
"S104",
"B008",
"C401",
"ISC001",
"SIM102",
"SIM105",
"RUF012", # We may want to enable "Mutable class attributes should be annotated with `typing.ClassVar`"
"PLR0911", # "Too many return statements"
"PLR0912", # "Too many branches"
"PLR0913", # "Too many arguments in function definition"
"PLR0915", # "Too many statements"
"PLR2004", # "Magic value used in comparison"
]
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []
[tool.ruff.lint.per-file-ignores]
# Allow `assert` and hardcoded passwords for tests.
# Ignore PLW0603 to be able to define global models from init fixture
"tests/*" = ["S101", "S105", "S106", "ASYNC230", "PLW0603"]
# Allow endpoints, tools and dependencies to raise `HTTPException` after catching an excetion without reraising (`from err`)
"**/endpoints_*" = ["B904"]
"**/cruds_*" = ["B904"] # TODO: find a better way to handle cruds errors
"app/utils/tools.py" = ["B904"]
# Ignore PLW0603 to be able to modify global variables in dependencies
"app/dependencies.py" = ["B904", "PLW0603"]
# Migrations folder should not really be part of a Python package
"migrations/env.py" = ["INP001"]
# Allow raw SQL for migrations, allow assert for migration tests
"migrations/versions/*" = ["S608", "S101"]
# Allow complexe methods for auth endpoints
"app/core/auth/endpoints_auth.py" = ["C901"]
[tool.ruff.lint.mccabe]
# Flag errors (`C901`) whenever the complexity level exceeds 18.
max-complexity = 18
[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"
# Like Black, indent with spaces, rather than tabs.
indent-style = "space"
# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
[tool.mypy]
python_version = "3.11"
plugins = ["pydantic.mypy"]
warn_unreachable = true
warn_unused_configs = true
warn_redundant_casts = true
warn_unused_ignores = true
strict_equality = true
check_untyped_defs = true
disallow_subclassing_any = true
disallow_untyped_decorators = true
no_implicit_reexport = true
warn_return_any = true
explicit_package_bases = true
warn_no_return = true
strict = true
# We currently don't type the return type of endpoints so we can not enable the two following rules
disallow_incomplete_defs = false
disallow_untyped_defs = false
disallow_any_generics = false
disallow_untyped_calls = false
[[tool.mypy.overrides]]
# google_auth_oauthlib : https://github.com/googleapis/google-auth-library-python-oauthlib/issues/288
# googleapiclient : https://github.com/googleapis/google-api-python-client/issues/2426
module = [
"firebase_admin",
"icalendar",
"fitz",
"google_auth_oauthlib.flow",
"googleapiclient.*",
]
ignore_missing_imports = true
[tool.pytest.ini_options]
asyncio_mode = "auto"
filterwarnings = [
"error",
# We don't know how to fix the warning:
# `ResourceWarning: connection <psycopg.Connection [IDLE] (host=... user=... database=...) at 0x1166bf310> was deleted while still open. Please use 'with' or '.close()' to close the connection`
# It only happen when running tests with Postgresql
"ignore:connection <.*> was deleted while still open.:ResourceWarning",
]
[tool.coverage.run]
source_pkgs = ["app"]
omit = [
"main.py", # Main is just a wrapper and is not used during tests
"mailworker.py", # We don't use send mails during tests
"*matrix*", # We don't send logs to matrix during tests
]
concurrency = [
"thread",
"greenlet",
] # Tell the tool that we also use greenlet, because sqlalchemy does
[tool.coverage.report]
# Regexes for lines to exclude from consideration
# See https://coverage.readthedocs.io/en/latest/excluding.html#excluding for more info
exclude_also = []
skip_covered = true
show_missing = true