diff --git a/changelog.d/20260802_issue_44_mypy_python_39.md b/changelog.d/20260802_issue_44_mypy_python_39.md new file mode 100644 index 0000000..9a0d9f1 --- /dev/null +++ b/changelog.d/20260802_issue_44_mypy_python_39.md @@ -0,0 +1,4 @@ +### Fixed + +- Keep the development mypy version below 2.0 while the template supports and + type-checks against Python 3.9. diff --git a/pyproject.toml b/pyproject.toml index 595125a..bd4fca7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ classifiers = [ [project.optional-dependencies] dev = [ "ruff>=0.8.0,<0.9", - "mypy>=1.13.0", + "mypy>=1.13.0,<2.0", "pytest>=8.3.0", "pytest-asyncio>=0.24.0", "pytest-cov>=6.0.0", diff --git a/tests/test_project_metadata.py b/tests/test_project_metadata.py new file mode 100644 index 0000000..6ecc352 --- /dev/null +++ b/tests/test_project_metadata.py @@ -0,0 +1,26 @@ +"""Regression tests for project package metadata.""" + +from __future__ import annotations + +from pathlib import Path + +from packaging.requirements import Requirement + +ROOT = Path(__file__).resolve().parents[1] + + +def dev_requirement(name: str) -> Requirement: + """Return one requirement from the project's ``dev`` dependency group.""" + pyproject = (ROOT / "pyproject.toml").read_text(encoding="utf-8") + dev_group = pyproject.split("dev = [", maxsplit=1)[1].split("]", maxsplit=1)[0] + requirement_lines = (line.strip().strip('",') for line in dev_group.splitlines()) + requirements = (Requirement(line) for line in requirement_lines if line) + return next(requirement for requirement in requirements if requirement.name == name) + + +def test_mypy_dependency_supports_configured_python_target() -> None: + """The dev extra must not install mypy versions that reject Python 3.9.""" + mypy = dev_requirement("mypy") + + assert "1.13.0" in mypy.specifier + assert "2.0" not in mypy.specifier