forked from Checkmk/checkmk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyproject.toml
227 lines (208 loc) · 8.66 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
[tool.ruff]
src = ["cmk", "tests"]
target-version = "py312"
line-length = 100
[tool.ruff.lint]
ignore = [
"E402", # module level import not on top of the file
"E501", # line too long, 100s of fails. Fixable.
"E731", # Do not assign a `lambda` expression, use a `def`
"E741", # amgiguous variable name (l, x, etc.)
"E713", # Test for membership should be `not in`
"E999", # SyntaxError, all due to missing "match" support in ruff. See: https://github.com/charliermarsh/ruff/issues/282
"S101", # assert detected
# Ignored in .flake8 but not here.
# F403 undefined imports, all are fixed now, but we shouldn't add new ones.
# F405 are * imports. We shouldn't do those.
]
select = ["E", "F", "YTT"]
# Interesting to enable:
# "RUF" - Remove unused "noqa" directives from the code, etc.
# "TRY" - remove those "raise Exception" calls. 1688 failures.
# "G" - wrong logging.log formattion! 107 failures
# "S" - emulate bandit. 12993 errors detected. Ignoring complaints about asserts, 335 failures remain.
# "PGH" - complain about blanket "type: ignore" without specifics.
# "T20" - complain about print found. 217 "failures" found. Needs some rework first!
# "DTZ" - disallows datetime objects without timezone, 254 failures.
# "UP" - emulate pyupgrade. 3024 failures, 3005 fixable automatically.
# "C4" - simplify comprehensions, 164 failures, 138 auto fixable
# "B" - bugbear, 756 failures, 71 auto fixable
# "ERA" - commented out code, 1717 failures, 1717 auto fixable
# "PL" - impersonate PyLint. 2819 failures, 1 auto fixable.
# "ARG" - unused arguments, 3358 failures
# "I" - replaces isort, but doesn't honor isort disable annotation yet, only "noqa: I001"
# "D" - enforces docstring writing style. Ignore "D10,D4" for now.
# "COM" - enforce trailing comma. Lots of matches.
unfixable = [
"F401", # pylint: disable=unused-import. Clean up by hand.
]
[tool.ruff.lint.per-file-ignores]
"cmk/gui/config.py" = ["F403", "F405"]
[tool.ruff.lint.flake8-annotations]
suppress-dummy-args = true
[tool.ruff.lint.mccabe]
max-complexity = 15
[tool.isort]
known_testlib = "tests.testlib"
known_compositiontests = "tests.composition"
known_integrationtests = "tests.integration"
known_unittests = "tests.unit,tests.plugins_integration,tests.update"
known_livestatus = "livestatus"
known_omd = "omdlib"
known_cmk_utils = "cmk.utils"
known_cmk_automations = "cmk.automations"
known_cmk_base = "cmk.base"
known_cmc_proto = "cmc_proto"
known_cmk_ec = "cmk.ec"
known_cmk_gui = "cmk.gui"
known_cmk_cee = "cmk.cee.dcd,cmk.cee.liveproxy,cmk.cee.mknotifyd"
known_cmk_notification_plugins = "cmk.notification_plugins"
known_cmk_snmplib = "cmk.snmplib"
known_cmk_fetchers = "cmk.fetchers"
known_cmk_checkengine = "cmk.checkengine"
known_werks = "werks"
known_first_party = "cmk"
# Order sections according to our layering.
sections = """FUTURE,STDLIB,THIRDPARTY,WERKS,CMC_PROTO,TESTLIB,INTEGRATIONTESTS,COMPOSITIONTESTS,UNITTESTS,LIVESTATUS,OMD,
CMK_UTILS,CMK_AUTOMATIONS,CMK_SNMPLIB,CMK_FETCHERS,CMK_CHECKENGINE,CMK_BASE,CMK_EC,CMK_GUI,CMK_CEE,
CMK_NOTIFICATION_PLUGINS,FIRSTPARTY,LOCALFOLDER"""
# configuration options compatible with black
multi_line_output = 3
include_trailing_comma = "True"
force_grid_wrap = 0
use_parentheses = "True"
ensure_newline_before_comments = "True"
order_by_type = "False"
line_length = 100
py_version = "312"
[tool.black]
line-length = 100
target-version = ['py312']
# 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]
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\
"""
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.crypto.*",
"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.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',
]
# When writing a junit.xml, also write the output of a test to the junit
# file in addition to the console.
junit_logging = "all"