-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathpyproject.toml
255 lines (246 loc) · 6.12 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
# Testing tools configuration
[tool.coverage.run]
branch = true
dynamic_context = "test_function"
[tool.coverage.report]
show_missing = true
[tool.pytest.ini_options]
minversion = "6.0"
log_cli_level = "INFO"
# Linting tools configuration
[tool.ruff]
line-length = 99
target-version = "py38"
extend-exclude = ["__pycache__", "*.egg_info", "htmlcov"]
# Ruff formatter configuration
[tool.ruff.format]
quote-style = "preserve" # FIXME: use double for consistency with current codebase convention
[tool.ruff.lint]
select = [
# flake8-builtins
"A",
# flake8-bugbear
"B",
# pyflakes-docstrings
"D",
# conventional names
"C",
# flake8-copyright
"CPY",
# Pycodestyle (error)
"E",
# Pyflakes
"F",
# flake8-logging-format
"G",
# isort
"I001",
# pep8-naming
"N",
# Perflint
"PERF",
# Ruff specific
"RUF",
# flake8-bandit
"S",
# flake8-simplify
"SIM",
# pyupgrade
"UP",
# Pycodestyle (warning)
"W",
# flake8-2020
"YTT",
]
ignore = [
# mccabe
"C90",
# Missing docstring in magic method
"D105",
# Missing docstring in `__init__`
"D107",
# Use of `assert` detected
"S101",
# `subprocess` module is possibly insecure
"S404",
# subprocess-without-shell-equals-true
# S602 complains if shell is True, which is considered worse due to potential shell exploits
# difficult to avoid without noqa, which then becomes meaningless boilerplate every time
"S603",
# start-process-with-partial-path
# wants an absolute path to the executable as the first argument
# seems impractical, so also results in noqa boilerplate
"S607",
# Return condition directly, prefer readability.
"SIM103",
# Use contextlib.suppress() instead of try/except: pass
"SIM105",
# Use a single `with` statement with multiple contexts instead of nested `with` statements
"SIM117",
]
[tool.ruff.lint.per-file-ignores]
"lib/charms/operator_libs_linux/v0/dnf.py" = [
# Use from err or from None explicitly
# FIXME
"B904",
# prefer capture_output over using stdout+stderr with PIPE
# FIXME
"UP022",
]
"lib/charms/operator_libs_linux/v0/grub.py" = [
# Probably insecure usage of temporary file or directory under /tmp
# FIXME: use stdlib tempfile
"S108",
# Unnecessary open mode parameters
# FIXME
"UP015",
]
"lib/charms/operator_libs_linux/v0/juju_systemd_notices.py" = [
# Line too long
# FIXME
"E501",
# unqualified noqa
# FIXME
"RUF100",
# Store a reference to the return value of `asyncio.create_task`
# FIXME: investigate
"RUF006",
]
"lib/charms/operator_libs_linux/v0/passwd.py" = [
# implicit Optional in typing
# FIXME: typing
"RUF013",
# Use fstrings instead of `format`
# FIXME: migrate to fstrings
"UP032",
]
"lib/charms/operator_libs_linux/v0/sysctl.py" = [
# Use from err or from None explicitly
# FIXME
"B904",
# use unpacking instead of concatenation with lists
# FIXME
"RUF005",
# Unnecessary open mode parameters
# FIXME
"UP015",
]
"lib/charms/operator_libs_linux/v1/systemd.py" = [
# Use from err or from None explicitly
# FIXME
"B904",
# don't use f-strings in logging
# FIXME: use %s for deferred evaluation
"G004",
]
"tests/*" = [
# All documentation linting.
"D",
# "Useless" expression.
"B018",
# Line too long (lots of raw data for comparisons)
"E501",
# Use of `assert` detected
"S101",
# Hard-coded password string.
"S105",
# Hard-coded password function argument.
"S106",
# Probably insecure usage of temporary file or directory (e.g. /tmp/bad.list)
"S108",
]
"tests/integration/helpers.py" = [
# Unnecessary open mode parameters
# FIXME
"UP015",
]
"tests/integration/test_apt.py" = [
# too many leading # before block comment
# FIXME
"E266",
# Use fstrings instead of `format`
# FIXME: migrate to fstrings
"UP032",
]
"tests/integration/test_passwd.py" = [
# function call with 'truthy' `shell` parameter
# FIXME
"S604",
# Use fstrings instead of `format`
# FIXME: migrate to fstrings
"UP032",
]
"tests/integration/test_snap.py" = [
# don't use str.format in logging
# FIXME: use %s for deferred evaluation
"G001",
# Use fstrings instead of `format`
# FIXME: migrate to fstrings
"UP032",
]
"tests/integration/test_sysctl.py" = [
# Unnecessary open mode parameters
# FIXME
"UP015",
]
"tests/integration/test_grub.py" = [
# detected, some yoda conditionals were
# FIXME
"SIM300",
]
"tests/unit/fake_snapd.py" = [
# Use fstrings instead of `format`
# FIXME: migrate to fstrings
"UP032",
]
"tests/unit/test_repo.py" = [
# use context manager for opening files
# FIXME
"SIM115",
]
"tests/unit/test_sysctl.py" = [
# combine if branches using logical or
# FIXME
"SIM114",
# Unnecessary open mode parameters
# FIXME
"UP015",
]
"tests/unit/test_snap.py" = [
# use unpacking instead of concatenation with lists
# FIXME
"RUF005",
# implicit Optional in typing
# FIXME: typing
"RUF013",
]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.pyright]
include = ["lib/charms/operator_libs_linux/v*/*.py", "tests/*/*.py"]
pythonVersion = "3.8" # check no python > 3.8 features are used
pythonPlatform = "All"
typeCheckingMode = "strict"
reportPrivateUsage = false # library classes may use each other's private attributes
reportUnnecessaryIsInstance = false # types aren't perfect
reportUnnecessaryComparison = false # types aren't perfect
reportUnnecessaryTypeIgnoreComment = "error" # unnecessary ignores should be removed
stubPath = "" # silence warning: https://github.com/microsoft/pyright/issues/777
[tool.codespell]
skip = [
".git",
".tox",
".mypy_cache",
".pytest_cache",
".ruff_cache",
".vscode",
"build",
"htmlcov",
"venv",
"icon.svg",
]
ignore-words-list = [
"assertIn",
"fpr", # gnupg2 fingerprint regex in apt lib
]
quiet-level = 3 # disable warnings about (1) wrong encoding + (2) binary files