Repository navigation
Expand file tree
/
Copy pathmypy.ini
More file actions
100 lines (91 loc) · 3.78 KB
/
Copy pathmypy.ini
File metadata and controls
100 lines (91 loc) · 3.78 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
# mypy's settings live apart from pyproject.toml on purpose: please don't merge them back.
#
# Every edit of the file holding them re-runs all mypy actions, in CI about 1420 of them (52-75
# CPU-minutes). In the year up to 2026-11-25, 20 of the 209 commits changing pyproject.toml
# changed neither ruff's settings (which live in ruff.toml for the same reason) nor mypy's, only
# pytest's, bandit's or coverage's, or just comments and formatting. The other way round, the 23
# commits changing mypy's settings re-ran all 1045 bandit actions (about 16 CPU-minutes) and the
# targets that depend on pyproject.toml, among them tests reading their pytest settings from it.
# Keeping mypy apart saves roughly 20-30 CPU-hours a year in CI, plus the rebuilds developers get
# after rebasing across such a commit.
#
# Keep the name: started in this directory or any directory below it, mypy finds a mypy.ini by
# itself, before pyproject.toml, so editors and plain mypy runs pick it up, too. mypy doesn't look
# for a mypy.toml. And mypy's INI format has no inline comments: put each one on its own line.
# Its INI parser also mangles deprecated_calls_exclude until python/mypy#22038 is released:
# suppress such calls with "# type: ignore[deprecated]" instead.
#
# NOTE: Keep this in sync with mypy-gpl.ini!
[mypy]
# Global options.
# Add per-module options as [mypy-<module patterns>] sections.
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.15
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 = True
# both: lots of findings all over the place
disallow_any_expr = False
disallow_any_unimported = False
strict_equality_for_none = True
warn_unreachable = True
# error codes which are not enabled by default
enable_error_code =
deprecated,
exhaustive-match,
explicit-override,
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
[mypy-cmc_proto.*]
disallow_untyped_calls = False
# meraki has no type annotations; with explicit_package_bases=true and mypy 1.19+, following it
# silently triggers "Source file found twice under different module names". Skip it entirely —
# all meraki types remain Any either way since the package ships no py.typed or stubs.
[mypy-meraki,meraki.*]
follow_imports = skip
[pydantic-mypy]
init_forbid_extra = True
init_typed = True
warn_required_dynamic_aliases = True