forked from Checkmk/checkmk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyproject.toml
265 lines (255 loc) · 10.5 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
[tool.ruff]
extend-exclude = ["agents/plugins/mk_sap_2.py", "doc/**/*.py"]
target-version = "py312"
line-length = 100
[tool.ruff.lint]
select = ["E", "F", "I", "W", "C90", "PL", "UP"]
ignore = [
# Black is our formatting tool, so ignore any formatting-related findings.
"E501", # line too long
# Ignore findings which are incompatible with our "import" techonology.
"F401", # 'FOO' imported but unused
"E402", # module level import not at top of file
"F403", # 'from FOO import *' used; unable to detect undefined names
"F405", # 'FOO' may be undefined, or defined from star imports: BAR
# 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
"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...
"UP004", # Class `_MockHttpResponse` inherits from `object`
"UP006", # Use `collections.defaultdict` instead of `DefaultDict` for type annotation
"UP007", # Use `X | Y` for type annotations
"UP009", # UTF-8 encoding declaration is unnecessary
"UP010", # Unnecessary `__future__` import `with_statement` for target Python version
"UP012", # Unnecessary call to `encode` as UTF-8
"UP015", # Unnecessary open mode parameters
"UP017", # Use `datetime.UTC` alias
"UP024", # Replace aliased errors with `OSError`
"UP025", # Remove unicode literals from strings
"UP026", # `mock` is deprecated, use `unittest.mock`
"UP028", # Replace `yield` over `for` loop with `yield from`
"UP031", # Use format specifiers instead of percent format
"UP032", # Use f-string instead of `format` call
"UP035", # Import from `FOO` instead: `BAR`
"UP036", # Version block is outdated for minimum Python version
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`
"UP040", # Type alias `FOO` uses `TypeAlias` annotation instead of the `type` keyword
"UP041", # Replace aliased errors with `TimeoutError`
]
[tool.ruff.lint.mccabe]
max-complexity = 64 # TODO: This is far too much, we need to lower this!
[tool.ruff.lint.isort]
# combine-as-imports = true # This would arguably be nicer.
known-first-party = ["cmk"]
order-by-type = false # TODO: Why do we actually want this?
section-order = [
"future",
"standard-library",
"third-party",
"werks",
"cmc_proto",
"testlib",
"integrationtests",
"compositiontests",
"unittests",
"livestatus",
"omd",
"cmk_ccc",
"cmk_utils",
"cmk_events",
"cmk_automations",
"cmk_snmplib",
"cmk_fetchers",
"cmk_checkengine",
"cmk_base",
"cmk_ec",
"cmk_gui",
"cmk_cee",
"cmk_notification_plugins",
"first-party",
"local-folder",
]
[tool.ruff.lint.isort.sections]
werks = ["werks"]
cmc_proto = ["cmc_proto"]
testlib = ["tests.testlib"]
integrationtests = ["tests.integration"]
compositiontests = ["tests.composition"]
unittests = ["tests.unit", "tests.plugins_integration", "tests.update"]
livestatus = ["livestatus"]
omd = ["omdlib"]
cmk_ccc = ["cmk.ccc"]
cmk_events = ["cmk.events"]
cmk_utils = ["cmk.utils"]
cmk_automations = ["cmk.automations"]
cmk_snmplib = ["cmk.snmplib"]
cmk_fetchers = ["cmk.fetchers"]
cmk_checkengine = ["cmk.checkengine"]
cmk_base = ["cmk.base"]
cmk_ec = ["cmk.ec"]
cmk_gui = ["cmk.gui"]
cmk_cee = ["cmk.cee.dcd", "cmk.cee.liveproxy", "cmk.cee.mknotifyd"]
cmk_notification_plugins = ["cmk.notification_plugins"]
# 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]
enable_error_code = [
# "explicit-override", # 9999 errors in 762 files
"ignore-without-code",
# "mutable-override", # 336 errors in 71 files
# "possibly-undefined", # 401 errors in 183 files
# "redundant-expr", # 115 errors in 86 files
"redundant-self",
"truthy-bool",
"truthy-iterable",
"unimported-reveal",
"unused-awaitable",
"unused-ignore",
]
explicit_package_bases = true
mypy_path = """\
$MYPY_CONFIG_FILE_DIR:\
$MYPY_CONFIG_FILE_DIR/non-free/cmc-protocols:\
$MYPY_CONFIG_FILE_DIR/non-free/cmk-update-agent:\
$MYPY_CONFIG_FILE_DIR/livestatus/api/python:\
$MYPY_CONFIG_FILE_DIR/omd/packages/omd:\
$MYPY_CONFIG_FILE_DIR/tests/typeshed:\
$MYPY_CONFIG_FILE_DIR/packages/cmk-trace\
"""
plugins = ["pydantic.mypy"]
python_version = "3.12"
scripts_are_modules = true
# When all of these are true, we can enable --strict
check_untyped_defs = true
disallow_any_generics = false # 1904 errors in 507 files
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_calls = false # 6427 errors in 1077 files
disallow_untyped_decorators = true
disallow_untyped_defs = false # 6738 errors in 1571
extra_checks = true
no_implicit_reexport = true
strict_equality = true
warn_redundant_casts = true
warn_return_any = false # 622 errors in 267 files
warn_unused_configs = true
warn_unused_ignores = true
# Miscellaneous stuff not in --strict
disallow_any_decorated = false # 3433 errors in 997 files
disallow_any_explicit = false # 2854 errors in 836 files
disallow_any_expr = false # 112427 errors in 3304 files
disallow_any_unimported = false # 291 errors in 46 files
no_implicit_optional = true
strict_optional = true
warn_unreachable = false # 240 errors in 133 files
# hidden flags for PEP 688 compat, see https://github.com/python/mypy/issues/15313
disable_bytearray_promotion = true
disable_memoryview_promotion = true
[[tool.mypy.overrides]]
module = [
"cmk.active_checks.check_sftp",
"cmk.cee.bakery.*",
"cmk.gui.background_job.*",
"cmk.gui.mobile.views",
"cmk.gui.views.layout.*",
"cmk.gui.wato.pages.bulk_discovery",
"cmk.gui.wato.pages.bulk_edit",
"cmk.gui.wato.pages.folders",
"cmk.gui.wato.pages.parentscan",
"cmk.gui.watolib.auth_php",
"cmk.gui.watolib.bulk_discovery",
"cmk.gui.watolib.config_sync",
"cmk.gui.watolib.main_menu",
"cmk.gui.watolib.network_scan",
"cmk.gui.watolib.registration",
"cmk.notification_plugins.*",
"cmk.update_config.*",
"cmk.utils.livestatus_helpers.*",
"tests.gui_e2e.*",
"tests.unit.cmk.ec.*",
"tests.unit.cmk.update_config.*",
]
disallow_untyped_calls = true
disallow_untyped_defs = true
warn_return_any = true
warn_unused_ignores = true
[[tool.mypy.overrides]]
module = ["cmk.gui.form_specs.*"]
disallow_any_generics = true
[[tool.mypy.overrides]]
module = ["cmk.ec.*"]
disallow_any_generics = true
disallow_untyped_calls = true
disallow_untyped_defs = true
warn_unreachable = true
[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:schemathesis",
"-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 schemathesis testing related warnings
'ignore:^jsonschema\.RefResolver is deprecated.*$:DeprecationWarning:schemathesis\..*:0',
'ignore:^jsonschema\.exceptions\.RefResolutionError is deprecated.*$:DeprecationWarning:schemathesis\..*:0',
'ignore:^Generating overly large repr.*$:Warning:hypothesis\..*: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.*',
]
# When writing a junit.xml, also write the output of a test to the junit
# file in addition to the console.
junit_logging = "all"