mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-04 22:35:08 +00:00
* ci: mypy ratchet -- keep type-clean modules clean mypy-clean.txt lists the 71 modules under src/ that type-check clean; scripts/check_types.py runs mypy (--follow-imports=silent) on exactly those files and fails on any error or a missing/unsorted/duplicate entry. A new "Type check (mypy ratchet)" CI job runs it with mypy 1.20.2 and pinned stubs; the manual pre-commit mypy hook now runs the same script (a local hook, so mypy sees the installed requirements like CI does). 35 modules were made clean with annotation-only fixes: hints, typing.cast, TYPE_CHECKING imports, implicit-Optional defaults made explicit, and annotations widened (never guards removed) where mypy called a defensive isinstance check unreachable. No runtime behaviour change. mypy.ini: numpy and orjson are treated as Any (follow_imports=skip, also for stubs). numpy 2.3+ stubs use 3.12 `type` statements that mypy won't parse at python_version 3.10, and orjson is optional, so seeing its stubs made the result depend on whether it was installed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: annotate check_types.py's list-form mypy subprocess Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
121 lines
2.9 KiB
INI
121 lines
2.9 KiB
INI
[mypy]
|
|
# Mypy configuration for LEDMatrix
|
|
|
|
# What a bare `mypy` checks. ini values can't span lines or carry trailing
|
|
# comments -- this file used to have both, so mypy refused to read it at all.
|
|
files = src
|
|
exclude = (^|/)(test|__pycache__)/
|
|
|
|
# Python version
|
|
python_version = 3.10
|
|
|
|
# Platform (Linux/Raspberry Pi)
|
|
platform = linux
|
|
|
|
# Follow imports
|
|
follow_imports = normal
|
|
|
|
# Ignore missing imports (for optional dependencies)
|
|
ignore_missing_imports = True
|
|
|
|
# Show error codes
|
|
show_error_codes = True
|
|
|
|
# Warn about unused ignores
|
|
warn_unused_ignores = True
|
|
|
|
# Warn about unreachable code
|
|
warn_unreachable = True
|
|
|
|
# Strict optional checking
|
|
strict_optional = True
|
|
|
|
# Disallow untyped definitions (set to True once all code is typed)
|
|
disallow_untyped_defs = False
|
|
|
|
# Disallow untyped calls (set to True once all code is typed)
|
|
disallow_untyped_calls = False
|
|
|
|
# Check untyped definitions
|
|
check_untyped_defs = True
|
|
|
|
# No implicit optional
|
|
no_implicit_optional = True
|
|
|
|
# Warn about return Any
|
|
warn_return_any = True
|
|
|
|
# Warn about unused configs
|
|
warn_unused_configs = True
|
|
|
|
# Per-module options
|
|
[mypy-src.*]
|
|
# Allow untyped for now, but check typed code
|
|
disallow_untyped_defs = False
|
|
disallow_untyped_calls = False
|
|
|
|
[mypy-src.cache_manager]
|
|
# Cache manager has comprehensive type hints
|
|
disallow_untyped_defs = True
|
|
disallow_untyped_calls = True
|
|
|
|
[mypy-src.config_manager]
|
|
# Config manager has comprehensive type hints
|
|
disallow_untyped_defs = True
|
|
disallow_untyped_calls = True
|
|
|
|
[mypy-src.plugin_system.*]
|
|
# Plugin system has type hints
|
|
disallow_untyped_defs = False
|
|
disallow_untyped_calls = False
|
|
|
|
[mypy-src.exceptions]
|
|
# Exceptions module
|
|
disallow_untyped_defs = True
|
|
|
|
# Ignore third-party libraries that may not have type stubs
|
|
[mypy-rgbmatrix.*]
|
|
ignore_missing_imports = True
|
|
|
|
[mypy-RGBMatrixEmulator.*]
|
|
ignore_missing_imports = True
|
|
|
|
[mypy-PIL.*]
|
|
ignore_missing_imports = True
|
|
|
|
[mypy-freetype.*]
|
|
ignore_missing_imports = True
|
|
|
|
[mypy-pytz.*]
|
|
ignore_missing_imports = True
|
|
|
|
[mypy-requests.*]
|
|
ignore_missing_imports = True
|
|
|
|
[mypy-Flask.*]
|
|
ignore_missing_imports = True
|
|
|
|
[mypy-google.*]
|
|
ignore_missing_imports = True
|
|
|
|
[mypy-spotipy.*]
|
|
ignore_missing_imports = True
|
|
|
|
|
|
# numpy's own stubs (numpy>=2.3) use Python 3.12 `type` statements, which mypy
|
|
# refuses to parse under python_version = 3.10 -- and 3.10 is the floor this
|
|
# code has to run on, so it stays. Treat numpy as Any instead: skip it, and
|
|
# follow_imports_for_stubs makes the skip apply to its .pyi files too.
|
|
[mypy-numpy.*]
|
|
follow_imports = skip
|
|
follow_imports_for_stubs = True
|
|
|
|
# orjson is optional (see requirements.txt): the modules that use it fall back
|
|
# to the stdlib when `import orjson` fails. Whether mypy sees its stubs would
|
|
# otherwise depend on whether it happens to be installed -- installed, the
|
|
# `orjson = None` fallback is a type error and the stdlib branch "unreachable";
|
|
# not installed, silencing either is an unused ignore. Treat it as Any always.
|
|
[mypy-orjson.*]
|
|
follow_imports = skip
|
|
follow_imports_for_stubs = True
|