If a project excludes a Python version through excluded-python-versions, check-dev-files still adds Python version classifiers for every newer version that requires-python allows. Since Python 3.15 was added to the known versions, a project that excludes Python 3.14 therefore gets a Python 3.15 classifier, as well as a test-py315 Poe task.
This surfaced in ComPWA/tensorwaves#589, which has requires-python = ">=3.10" and excluded-python-versions = "3.14", because TensorFlow provides no wheels for Python 3.14. TensorFlow does not support Python 3.15 either, so the new classifier and test task are wrong. The repository can work around this by excluding "3.15" as well, but that has to be repeated for every new Python version.
Steps to reproduce
mkdir excluded-python-repro && cd excluded-python-repro
git init -q
mkdir tests && touch tests/__init__.py
cat > pyproject.toml <<'EOF'
[project]
classifiers = [
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
name = "my-package"
requires-python = ">=3.12"
version = "0.0.0"
[tool.compwa.policy]
dev-python-version = "3.13"
[tool.compwa.policy.python]
excluded-python-versions = "3.14"
EOF
cat > .pre-commit-config.yaml <<'EOF'
repos:
- repo: https://github.com/ComPWA/policy
rev: 236312689a32ad00fdef6d738e80eb38e8687dbb
hooks:
- id: check-dev-files
EOF
git add -A
prek run check-dev-files --all-files
The hook reports "Updated Python version classifiers" and adds "Programming Language :: Python :: 3.15" to the classifiers.
Cause
_update_python_version_classifiers() derives the classifiers from requires-python with _get_allowed_versions(), which only removes the excluded versions themselves. Every version newer than an excluded one is still listed if it satisfies requires-python.
Possible fix
A Python version is usually excluded because a dependency does not support it yet, and such a dependency will not support newer versions either. Possible solutions:
- Exclude every version newer than the latest excluded version as well, so that
excluded-python-versions = "3.14" acts as an upper bound until the exclusion is removed.
- Only add a newer version than an excluded one if its classifier is already listed, so that a project can still opt in by hand.
In both cases, the derived test tasks and CI test matrix should follow the classifiers.
If a project excludes a Python version through
excluded-python-versions,check-dev-filesstill adds Python version classifiers for every newer version thatrequires-pythonallows. Since Python 3.15 was added to the known versions, a project that excludes Python 3.14 therefore gets a Python 3.15 classifier, as well as atest-py315Poe task.This surfaced in ComPWA/tensorwaves#589, which has
requires-python = ">=3.10"andexcluded-python-versions = "3.14", because TensorFlow provides no wheels for Python 3.14. TensorFlow does not support Python 3.15 either, so the new classifier and test task are wrong. The repository can work around this by excluding"3.15"as well, but that has to be repeated for every new Python version.Steps to reproduce
The hook reports "Updated Python version classifiers" and adds
"Programming Language :: Python :: 3.15"to the classifiers.Cause
_update_python_version_classifiers()derives the classifiers fromrequires-pythonwith_get_allowed_versions(), which only removes the excluded versions themselves. Every version newer than an excluded one is still listed if it satisfiesrequires-python.Possible fix
A Python version is usually excluded because a dependency does not support it yet, and such a dependency will not support newer versions either. Possible solutions:
excluded-python-versions = "3.14"acts as an upper bound until the exclusion is removed.In both cases, the derived test tasks and CI test matrix should follow the classifiers.