Type check against the oldest Python version

Without a configured version, `mypy` and `pyright`
check against the Python that runs them.

With `MAIN_PYTHON` at 3.14, they would accept
`stdlib` APIs and `typing` features new in 3.14.

Yet, `requires-python` promises 3.13;
so, the type checkers must flag such code.

`black` and `ruff` already target 3.13 for the same reason.
This commit is contained in:
Alexander Hess 2026-12-02 21:41:00 +01:00
commit 67917ae3f6
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -439,6 +439,9 @@ force_single_line = true
cache_dir = ".cache/mypy"
# Check against the oldest supported Python version, not the one running `mypy`
python_version = "3.13"
# Check the interior of functions without type annotations
check_untyped_defs = true
@ -528,6 +531,9 @@ ignore_missing_imports = true
[tool.pyright]
# Source: https://microsoft.github.io/pyright/#/configuration
# Check against the oldest supported Python version, not the one running `pyright`
pythonVersion = "3.13"
# Treat libraries without type annotations as `Any`, like `mypy` does
useLibraryCodeForTypes = false