-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathpyproject.toml
More file actions
388 lines (366 loc) · 16.1 KB
/
pyproject.toml
File metadata and controls
388 lines (366 loc) · 16.1 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
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
[project]
name = 'system_tests'
version = '0.0.1'
dynamic = ["dependencies"]
[tool.setuptools]
packages = ["tests", "utils", "manifests"]
[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
[tool.pytest.ini_options]
addopts = "--json-report --json-report-indent=2 --color=yes --no-header -r Xf"
testpaths = [
"tests",
]
# log_cli = True
# log_cli_level = DEBUG
log_level = "DEBUG"
log_format = "%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s"
log_date_format = "%H:%M:%S"
log_file_format = "%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s"
log_file_date_format = "%H:%M:%S"
junit_family = "xunit2"
junit_logging = "no"
junit_duration_report = "call"
junit_suite_name = "system_tests_suite"
markers =[
"scenario: run a test only for a specified scenario",
"features: declare the feature id",
"owners: declare the owner of the test",
"declaration: declare the expected outcome of a test",
"skip_if_xfail: skip the test if it is marked as xfail",
"auxiliary_test: Do not count this test to determine if the scenario should run with the SYSTEM_TESTS_SKIP_EMPTY_SCENARIO option"
]
python_files = "test_*.py *utils.py"
[tool.mypy]
python_version = "3.12"
files = [
"utils/",
"tests/",
"conftest.py",
]
exclude = [
"utils/build/.*", # more permissive on weblog codes
"utils/grpc/weblog_pb2.py", # auto generated
# TODO
"utils/_context/_scenarios/auto_injection.py",
"utils/k8s_lib_injection/.*",
"utils/onboarding/.*",
"utils/virtual_machine/.*",
]
ignore_missing_imports = true
check_untyped_defs = true
disable_error_code = ["no-redef"]
follow_imports = "skip"
# enable_error_code = ["ignore-without-code"]
[tool.ruff]
line-length = 120
indent-width = 4
target-version = "py312"
[tool.ruff.lint.pep8-naming]
ignore-names = ["Test*", ] # TODO : lot of renamings to do...
[tool.ruff.format]
exclude = [
"venv/",
"utils/grpc/weblog_pb2_grpc.py",
"utils/grpc/weblog_pb2.py",
"parametric/apps",
"lib-injection/build/docker/python/dd-lib-python-init-test-protobuf-old/addressbook_pb2.py"
]
quote-style = "double"
indent-style = "space"
# skip-magic-trailing-comma = false
# line-ending = "auto"
# docstring-code-format = false
# docstring-code-line-length = "dynamic"
[tool.ruff.lint]
exclude = [
"docs/*", # ignore docs. But may be a good idea to enable rules here
"utils/grpc/{weblog_pb2_grpc.py,weblog_pb2.py}", # generated files
"lib-injection/build/docker/python/dd-lib-python-init-test-protobuf-old/addressbook_pb2.py", # generated file
]
select = ["ALL"]
ignore = [
### TODO : remove those ignores
"ANN202", # missing-return-type-private-function: TODO (877 occurences)
"BLE001", # blind-except: TODO big project to enable this (39 occurences)
"C901", # complex-structure: TODO (52 occurences)
"PERF401", # manual-list-comprehension: TODO TBD, the "good" code can be harder to read (13 occurences)
"PLR0911", # too-many-return-statements: TODO (7 occurences)
"PLR0912", # too-many-branches: TODO (17 occurences)
"PLR0913", # too-many-arguments: TODO (66 occurences)
"PLR0915", # too-many-statements: TODO (7 occurences)
"PTH118", # os-path-join: TODO (59 occurences)
"PTH123", # builtin-open: TODO (117 occurences)
"RUF012", # mutable-class-default: TODO (111 occurences)
"S202", # tarfile-unsafe-members: TODO (2 occurences)
"SIM102", # collapsible-if: TODO (22 occurences)
"TRY003", # raise-vanilla-args: TODO this is a full project to enable this (254 occurences)
### Ignores that will be kept for the entire project
"ANN204", # missing-return-type-special-method
"COM812", # ruff format recommend ignoring this
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
"D105", # Missing docstring in magic method
"D107", # Missing docstring in `__init__`
"D202", # blank line after docstring
"D203", # cause a warning
"D205", # PEP 257 : blank line after first docstring line
"D211", # no-blank-line-before-class
"D213", # multi-line-summary-second-line
"D400", # First line should end with a period
"D401", # PEP 257 : blank line after first docstring line
"D406", # we are not using numpy convention for docstrings
"D407", # we are not using reStructuredText for docstrings
"D415", # First line should end with a period
"EM101", # Exception must not use a string literal => painful
"EM102", # Exception must not use an f-string => painful
"ERA001", # Found commented-out code
"FIX001", # Fixme found
"FIX002", # Fixme found
"G004", # allow logging with f-string
"I001", # Import block is un-sorted or un-formatted
"ISC001", # ruff format recommend ignoring this
"PTH207", # allow using glob.glob
"S101", # we allow assert!
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes -> it's testing
"S324", # testing, it's fine
"S603", # allow untrusted input for subprocess
"S607", # allow relative process call
"TD001", # todo found
"TD002", # todo found
"TD003", # todo found
"TD004", # todo found
"TRY300", # not always obvious
"UP015", # redundant-open-modes: yes it's redundant. But explicit is better than implicit
]
[tool.ruff.lint.per-file-ignores]
# Rules for this section:
#
# 1. keep everything sorted alphabetically
# 2. on each line, comment with the rule name, and a comment, either TODO, or a reason why the rule is ignored
"lib-injection/build/docker/python/*" = [
"ANN001", # missing-type-function-argument
"ANN201", # missing-return-type-undocumented-public-function
"ARG001", # unused-function-argument
"INP001", # implicit-namespace-package
"PLC0415", # import-outside-top-level TODO
"PTH119", # os-path-basename
"PTH122", # os-path-splitext
"PTH208", # os-listdir: TODO
"RET503", # implicit-return
"S105", # hardcoded-password-string
"T201", # print
"UP031", # printf-string-formatting
]
"tests/*test_*.py" = [
"ANN201", # missing-return-type-undocumented-public-function: allow test_method to not declare their return type
]
"tests/*" = [
"E501", # line-too-long: TODO
"TRY002", # raise-vanilla-class: TODO
"TRY301", # raise-within-try: TODO
# keep those exceptions
"C400", # unnecessary-generator-list: explicit list is more readable for non-python users
"C401", # unnecessary-generator-set: explicit set is more readable for non-python users
"C408", # unnecessary-collection-call: explicit tuple is more readable for non-python users
"C416", # unnecessary-comprehension: may make the code less readable for non-python users
"D404", # docstring-starts-with-this: ruff, please don't be a pain
"FIX003", # line-contains-xxx: freedom of speech!
"FIX004", # line-contains-xxx: freedom of speech!
"PLR1730", # if-stmt-min-max: not clear that it makes the code easier to read
"PLR2004", # magic-value-comparison: test code has lot of hardocded values
"PT011", # pytest-raises-too-broad: kind of painful to fix
"RET506", # superfluous-else-raise: requires a slightly higher cognitive effort to understand the code
"RET507", # superfluous-else-continue : requires a slightly higher cognitive effort to understand the code
"RET508", # superfluous-else-break: requires a slightly higher cognitive effort to understand the code
"RET505", # superfluous-else-return: requires a slightly higher cognitive effort to understand the code
"RUF005", # collection-literal-concatenation: more pythonic, but less clear for non python users
"RUF015", # unnecessary-iterable-allocation-for-first-element: it makes the code a little bit less clear for non python users
"S105", # hardcoded-password-string: test code may contains weird things
"S108", # hardcoded-temp-file: test code may contains weird things
"SIM108", # if-else-block-instead-of-if-exp: ternary operator nay be harder to read on long statements
]
"tests/auto_inject/*" = [
"ANN001", # missing-type-function-argument: TODO
"RUF059", # unused-unpacked-variable: TODO
"SLF001", # private-member-access: TODO
]
"tests/fuzzer/*" = [
"T201", # print: fuzzer use prints...
]
"tests/fuzzer/request_mutator.py" = [
"RUF001", # ambiguous-unicode-character-string: the mutator contains weird strings on purpose
]
"tests/parametric/{test_headers_baggage.py,test_headers_datadog.py,test_library_tracestats.py}" = [
"N802", # invalid-function-name: some tests methods contains code with capital letters
]
"tests/perfs/*" = [
"ANN001", # missing-type-function-argument: TODO
"T201", # print: perfs use prints...
]
"tests/test_the_test/*" = [
"S605", # start-process-with-a-shell: test the test needs to run shell commands
]
"utils/_context/_scenarios/auto_injection.py" = [
"ANN001", # missing-type-function-argument: TODO
"PLC0415", # import-outside-top-level TODO
]
"utils/{_context/_scenarios/docker_ssi.py,docker_ssi/docker_ssi_matrix_utils.py}" = [
"ANN001", # missing-type-function-argument: TODO
"E501", # line-too-long: TODO
"T201", # print: TODO
"RET504", # unnecessary-assign: TODO
"RET505", # superfluous-else-return: TODO
"SIM108", # if-else-block-instead-of-if-exp: TODO
"SIM210", # if-expr-with-true-false: TODO
"PLR2004", # magic-value-comparison: TODO
]
"utils/_features.py" = [
"ANN001", # missing-type-function-argument: obvious decorators
"ANN205" # missing-return-type-static-method: obvious decorators
]
"utils/build/*" = ["ALL"] # mostly python weblog code. it may be a good idea to enable rules here
"utils/docker_ssi/*" = [
"ANN001", # missing-type-function-argument: TODO
"ANN201", # missing-return-type-undocumented-public-function: TODO
"ANN205", # issing-return-type-static-method: TODO
]
"utils/{k8s_lib_injection/*,_context/_scenarios/k8s_lib_injection.py}" = [
"ANN003", # missing-type-kwargs: TODO
"ANN201", # missing-return-type-undocumented-public-function: TODO
"B006", # mutable-argument-default: TODO
"B007", # unused-loop-control-variable: TODO
"B904", # raise-without-from-inside-except: TODO
"DTZ005", # call-datetime-now-without-tzinfo: TODO
"E401", # multiple-imports-on-one-line: TODO
"E501", # line-too-long: TODO
"E712", # true-false-comparison: TODO
"F541", # f-string-missing-placeholders: TODO
"FBT002", # boolean-default-value-positional-argument: TODO
"RET505", # superfluous-else-return: TODO
"RET508", # superfluous-else-break: TODO
"RUF059", # unused-unpacked-variable: TODO
"SIM108", # if-else-block-instead-of-if-exp: TODO
"SIM115", # open-file-with-context-handler: TODO
"SLF001", # private-member-access: TODO
"TRY002", # raise-vanilla-class: TODO
"TRY201", # verbose-raise: TODO
"TRY301", # raise-within-try: TODO
"UP031", # printf-string-formatting: TODO
]
"utils/onboarding/*" = [
"ANN201", # missing-return-type-undocumented-public-function: TODO
"DTZ005", # call-datetime-now-without-tzinfo: TODO
"DTZ006", # call-datetime-fromtimestamp: TODO
"E501", # line-too-long: TODO
"FBT001", # boolean-type-hint-positional-argument: TODO
"FBT002", # boolean-default-value-positional-argument: TODO
"N803", # invalid-argument-name: TODO
"N806", # non-lowercase-variable-in-function: TODO
"PLR2004", # magic-value-comparison: TODO
"PLR2044", # empty-comment: TODO
"PTH102", # os-mkdir: TODO
"RET505", # superfluous-else-return: TODO
"S507", # ssh-no-host-key-verification: TODO
"UP017", # datetime-timezone-utc: TODO
]
"utils/scripts/ssi_wizards/aws_onboarding_wizard_utils.py" = [
"ANN001", # missing-type-function-argument: TODO
"PLR2004", # magic-value-comparison: TODO
]
"utils/scripts/*" = [
"INP001", # implicit-namespace-package: this is not a package
"LOG015", # usage of logging
"PTH208", # os-listdir: TODO
"T201", # print: allow print statements in scripts folder
]
"utils/virtual_machine/virtual_machines.py" = [
"ANN003", # missing-type-kwargs: TODO
"ANN201", # missing-return-type-undocumented-public-function: TODO
"ARG002", # unused-method-argument: TODO
"FBT002", # boolean-default-value-positional-argument: TODO
"PLC0415", # import-outside-top-level TODO
"PLR2004", # magic-value-comparison: TODO
"TRY002", # raise-vanilla-class: TODO
]
"utils/virtual_machine/aws_provider.py" = [
"ANN201", # missing-return-type-undocumented-public-function: TODO
"E501", # line-too-long: TODO
"F541", # f-string-missing-placeholders: TODO
"RET504", # unnecessary-assign: TODO
"FBT002", # boolean-default-value-positional-argument: TODO
"PTH119", # os-path-basename: TODO
"N806", # non-lowercase-variable-in-function: TODO
"S113", # request-without-timeout: TODO
"A002", # builtin-argument-shadowing: TODO
"SIM115", # open-file-with-context-handler: TODO
"ARG002", # unused-method-argument: TODO
"PTH113", # os-path-isfile: TODO
"PTH208", # os-listdir: TODO
"N802", # invalid-function-name: TODO
"F841", # unused-variable: TODO
"TRY002", # raise-vanilla-class: TODO
"PLR2004", # magic-value-comparison: TODO
]
"utils/virtual_machine/krunvm_provider.py" = [
"A002", # builtin-argument-shadowing: TODO
"ANN002", # missing-type-args: TODO
"ANN201", # missing-return-type-undocumented-public-function: TODO
"ARG002", # unused-method-argument: TODO
"E501", # line-too-long: TODO
"F811", # redefined-while-unused: TODO
"FBT002", # boolean-default-value-positional-argument: TODO
"N803", # invalid-argument-name: TODO
"PLW1510", # subprocess-run-without-check: TODO
"PTH101", # os-chmod: TODO
"PTH102", # os-mkdir: TODO
"PTH109", # os-getcwd: TODO
"PTH116", # os-stat: TODO
"S103", # bad-file-permissions: TODO
"S602", # subprocess-popen-with-shell-equals-true: TODO
"SIM103", # needless-bool: TODO
"SLF001", # private-member-access: TODO
]
"utils/virtual_machine/utils.py" = [
"ANN201", # missing-return-type-undocumented-public-function: TODO
"E501", # line-too-long: TODO
"PLC0415", # import-outside-top-level TODO
"RET503", # implicit-return: TODO
"RET504", # unnecessary-assign: TODO
"SIM300", # yoda-conditions: TODO
]
"utils/virtual_machine/vagrant_provider.py" = [
"A002", # builtin-argument-shadowing: TODO
"ANN201", # missing-return-type-undocumented-public-function: TODO
"ARG002", # unused-method-argument: TODO
"E501", # line-too-long: TODO
"F541", # f-string-missing-placeholders: TODO
"FBT002", # boolean-default-value-positional-argument: TODO
"PLW1510", # subprocess-run-without-check: TODO
"PTH113", # os-path-isfile: TODO
"PTH208", # os-listdir: TODO
"RUF059", # unused-unpacked-variable: TODO
"UP008", # super-call-with-parameters: TODO
"UP024", # os-error-alias: TODO
"UP031", # printf-string-formatting: TODO
]
"utils/virtual_machine/virtual_machine_provider.py" = [
"A002", # builtin-argument-shadowing: TODO
"ANN201", # missing-return-type-undocumented-public-function: TODO
"ARG002", # unused-method-argument: TODO
"E501", # line-too-long: TODO
"E731", # lambda-assignment: TODO
"F541", # f-string-missing-placeholders: TODO
"FBT002", # boolean-default-value-positional-argument: TODO
"PLC0415", # import-outside-top-level TODO
"PTH112", # os-path-isdir: TODO
"PTH119", # os-path-basename: TODO
"RET505", # superfluous-else-return: TODO
]
"utils/virtual_machine/virtual_machine_provisioner.py" = [
"S506", # unsafe-yaml-load: TODO
]
"utils/waf_rules.py" = ["N801"] # generated file