-
Notifications
You must be signed in to change notification settings - Fork 532
Expand file tree
/
Copy pathpyproject.toml
More file actions
264 lines (248 loc) · 10.4 KB
/
pyproject.toml
File metadata and controls
264 lines (248 loc) · 10.4 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
[tool.bandit]
exclude_dirs = ["tests"]
skips = [
"B104", # hardcoded_bind_all_interfaces -> high false-positive rate ref: CMK-15199
"B314", # xml_bad_ElementTree consider safe since python 3.6 >= ref: CMK-15194
"B318", # xml_bad_minidom same as above
# "B415", # pyghmi is needed by our core
]
[tool.ruff]
extend-exclude = ["doc/**/*.py"]
target-version = "py313"
line-length = 100
[pytest]
xfail_strict = true
[tool.ruff.lint]
select = [
"A", # flake8: builtins
"ARG", # flake8: unused args
"C90", # mccabe
"E", # pycodestyle (error)
"F", # pyflakes
"N804", # pep8-naming: invalid-first-argument-name-for-class-method (cls)
"N805", # pep8-naming: invalid-first-argument-name-for-method (self)
"I", # isort
"PL", # pylint
"RUF100", # ruff: unused noqa
"SLF", # flake8: self
"UP", # pyugrade
"W", # pycodestyle (warning)
"T10", # flake8: debugger
"T20", # flake8: print
]
ignore = [
# Black is our formatting tool, so ignore any formatting-related findings.
"E501", # line too long
# We should probably have a look at these findings.
"E731", # do not assign a lambda expression, use a def
"E741", # ambiguous variable name 'FOO'
# pylint doesn't complain about these
"PLC0414", # Import alias does not rename original package
"PLC0415", # `import` should be at the top-level of a file
"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, consider replacing `FOO` with a constant variable
"PLR2044", # Line with empty comment
"PLW0603", # Using the global statement to update `FOO` is discouraged
"PLW2901", # `for` loop variable `FOO` overwritten by assignment target
# Basically a TODO list...
"PLW1641", # Object does not implement `__hash__` method
"UP031", # Use format specifiers instead of percent format
]
[tool.ruff.lint.per-file-ignores]
"cmk/*" = [
"A001",
"A002",
"A004",
"ARG001",
"ARG002",
"ARG003",
"ARG004",
"ARG005",
"SLF001",
]
"packages/cmk-ec/*" = ["ARG001", "ARG002"]
"packages/cmk-logwatch/tests/*" = ["ARG001", "ARG002"]
"packages/cmk-plugins/*" = ["ARG001", "ARG002"]
"packages/cmk-plugin-apis/*" = ["ARG002"]
"non-free/packages/cmk-dcd/*" = ["ARG001", "ARG002", "ARG003", "SLF001"]
"non-free/packages/cmk-mknotifyd/*" = ["ARG001", "ARG002", "SLF001"]
"non-free/packages/cmk-metric-backend/cmk/plugins/*" = ["ARG001"]
"non-free/packages/cmk-plugins-nonfree/cmk/plugins/*" = ["ARG001", "ARG002"]
"tests/*" = ["ARG001", "ARG002", "ARG003", "ARG004", "ARG005", "SLF001", "T20"]
".claude/skills/*" = ["T20"]
".github/skills/*" = ["T20"]
"buildscripts/*" = ["T20"]
"scripts/*" = ["T20"]
"bazel/tools/*" = ["T20"]
"packages/cmk-livestatus-client/example*.py" = ["T20"]
"packages/*/tests/*" = ["T20"]
"non-free/packages/*/tests/*" = ["T20"]
"**/testlib/*" = ["T20"]
"agents/*" = ["ARG001", "ARG002", "SLF001"]
"agents/wnx/*" = ["T20"]
"agents/modules/*" = ["T20"]
# Agent plugins still need to support Python 3.4
"agents/plugins/*" = [
"UP007", # PEP 604 (Allow writing union types as X | Y) is a Python 3.10 feature
"UP032", # PEP 498 (Literal String Interpolation) is a Python 3.6 feature
"UP041", # socket.timeout is an alias of TimeoutError only for Python >= 3.10
]
"cmk/plugins/*/agents/*.py" = [
"UP007", # PEP 604 (Allow writing union types as X | Y) is a Python 3.10 feature
"UP032", # PEP 498 (Literal String Interpolation) is a Python 3.6 feature
"UP041", # socket.timeout is an alias of TimeoutError only for Python >= 3.10
]
"tests/agent-plugin-unit/*" = [
"UP006", # PEP 585 (Type Hinting Generics In Standard Collections) is a Python 3.9 feature
"UP007", # PEP 604 (Allow writing union types as X | Y) is a Python 3.10 feature
"UP035", # PEP 585 (Type Hinting Generics In Standard Collections) is a Python 3.9 feature
"UP045", # PEP 604 (Allow writing union types as X | Y) is a Python 3.10 feature
]
[tool.ruff.lint.mccabe]
max-complexity = 64 # TODO: This is far too much, we need to lower this!
[tool.ruff.lint.isort]
known-first-party = ["agents", "buildscripts", "cmk", "tests"]
known-third-party = [
"requirements", # avoid confusion with our toplevel directory
]
order-by-type = false
section-order = [
"future",
"standard-library",
"third-party",
"first-party-not-cmk",
"first-party",
"local-folder",
]
[tool.ruff.lint.isort.sections]
first-party-not-cmk = ["cmc_proto", "omdlib", "livestatus"]
# NOTE: Keep this is sync with mypy-raw.ini!
# The number of errors/files below are just a snapshot to give a rough idea. In
# addition, a single cause can imply multiple symptoms, so these numbers have to
# be taken with a grain of salt...
[tool.mypy]
# Global options.
# Add per-module options as [[tool.mypy.overrides]].
explicit_package_bases = true
# TODO: `mypy_path` shouldn't be required with Bazel.
# Even though mypy_path is not needed anymore for Bazel based jobs, it still needed for e.g. editor
# integrations, which typically run mypy outside of Bazel so far.
# cmk-update-agent is needed for now because cmk_update_agent is still imported by some composition
# tests. Can hopefully be cleaned up in a following step.
mypy_path = """\
$MYPY_CONFIG_FILE_DIR/non-free/packages/cmk-update-agent:\
$MYPY_CONFIG_FILE_DIR/omd/packages/omd:\
$MYPY_CONFIG_FILE_DIR/tests/typeshed:\
"""
plugins = ["pydantic.mypy"]
python_version = "3.13"
scripts_are_modules = true
# do not descend into 3rd party dependencies
follow_imports = "silent"
follow_imports_for_stubs = true
# hidden flags for PEP 688 compat, see https://github.com/python/mypy/issues/15313
disable_bytearray_promotion = true
disable_memoryview_promotion = true
# checks enabled via --strict
check_untyped_defs = true
disallow_any_generics = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
extra_checks = true
no_implicit_reexport = true
strict_bytes = true
strict_equality = true
warn_redundant_casts = true
warn_return_any = true
warn_unused_configs = true
warn_unused_ignores = true
# additional checks not enabled via --strict
disallow_any_decorated = true
disallow_any_explicit = false # lots of findings all over the place
disallow_any_expr = false # lots of findings all over the place
disallow_any_unimported = false # lots of findings all over the place
strict_equality_for_none = true
warn_unreachable = true
# error codes which are not enabled by default
enable_error_code = [
"deprecated",
"exhaustive-match",
# "explicit-override", # lots of findings all over the place
"ignore-without-code",
"mutable-override",
"possibly-undefined",
"redundant-expr",
"redundant-self",
"truthy-bool",
"truthy-iterable",
"unimported-reveal",
"unused-awaitable",
"unused-ignore",
]
# Do not complain about --strict problems in generated protobuf code
[[tool.mypy.overrides]]
module = ["cmc_proto.*"]
disallow_untyped_calls = false
[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true
warn_untyped_fields = true
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = [
# Live logs initially look like a good idea to pin down problems in the tests
# quickly, but with the current state of our tests it's simply too much noise.
# Even in a successful unit test run, you get more than 70 log messages
# cluttering up the output and making it hard to use: saml2.client logs already
# at load time, tons of our own tests emit warnings up to ERROR even when
# successful, etc. etc. We might reconsinder lowering the live log level when we
# have cleaned up things...
"--log-cli-level=CRITICAL",
"--log-cli-format=%(asctime)s %(levelname)s %(message)s",
# Show summary of skipped tests
"-rs",
# Show N slowest setup/test durations
"--durations=20",
# Disable a few plugins which slow down the pytest startup even when not used
"-p no:faker",
"-p no:hypothesispytest",
]
markers = [
"checks: Run all existing test cases for checks.",
"slow: Run tests which take relatively larger time to execute.",
]
# See: https://docs.python.org/3/library/warnings.html#the-warnings-filter
filterwarnings = [
# Breaking change, only in new major version, see https://github.com/marshmallow-code/apispec/pull/759
'ignore:^distutils Version classes are deprecated\. Use packaging.version instead\.$:DeprecationWarning:apispec.utils:0',
# Internal copy of distutils in setuptools :-P
'ignore:^distutils Version classes are deprecated\. Use packaging.version instead\.$:DeprecationWarning:distutils.version:0',
# We have a doctest which intentionally checks for a failure
'ignore:^Invalid value for tag-group tag_agent. None$:UserWarning:cmk.gui.fields.definitions:0',
# Make marshmallow warnings errors, otherwise typos may go unnoticed.
'error::marshmallow.warnings.RemovedInMarshmallow4Warning',
# Fun fact: pkg_resources calls declare_namespace() itself when it processes namespace_packages.txt files.
'ignore:Deprecated call to `pkg_resources\.declare_namespace:DeprecationWarning:pkg_resources:0',
# ignore DeprecationWarning for ast.NameConstant in reportlab <= 4.2
'ignore:^ast\.NameConstant is deprecated and will be removed in Python 3\.14\; use ast\.Constant instead$:DeprecationWarning:reportlab\..*:0',
# ignore warnings caused by probuf 4.25.3 until updating to 5.x
'ignore:^Type google\._upb\._message.MessageMapContainer uses PyType_Spec with a metaclass that has custom tp_new\. This is deprecated and will no longer be allowed in Python 3\.14\.$:DeprecationWarning:importlib._bootstrap:488',
'ignore:^Type google\._upb\._message.ScalarMapContainer uses PyType_Spec with a metaclass that has custom tp_new\. This is deprecated and will no longer be allowed in Python 3\.14\.$:DeprecationWarning:importlib._bootstrap:488',
# ignore PytestCollectionWarning caused by webtest
'ignore:^cannot collect test class .* because it has a __init__ constructor.*$:UserWarning:.*webtest.*:0',
# openapi collector uses pkg resources
'ignore:pkg_resources:DeprecationWarning:.*opentelemetry.*',
# ignore pysnmp warnings
'ignore:^(smiV1Relaxed|getReadersFromUrls) is deprecated:DeprecationWarning:pysnmp\.smi\..*:0',
]
# When writing a junit.xml, also write the output of a test to the junit
# file in addition to the console.
junit_logging = "all"
asyncio_default_fixture_loop_scope = "function"