Repository navigation
check-peps: validate every Python-Version entry, not just the first - #5225
Closed
Dhairya-007 wants to merge 2 commits into
Closed
Dhairya-007 wants to merge 2 commits into
Dhairya-007 wants to merge 2 commits into
Conversation
…sion
_validate_python_version loops over the comma-separated versions in the header,
but the "no micro part" branch used return rather than continue. Because it is
a generator, that ended the whole validation instead of moving to the next
version, so everything after the first X.Y version went unchecked:
_validate_python_version(1, "3.0, 3.a") -> no warnings
_validate_python_version(1, "3.12, 4.0") -> no warnings
_validate_python_version(1, "3.11, 3.x.1") -> no warnings
_validate_python_version(1, "3.9, 3.09") -> no warnings
Two-segment versions are the overwhelming majority, so in practice only the
first entry of a Python-Version header was ever validated. The checks all still
existed; they were simply unreachable.
An AST sweep for return inside a loop in a generator turns up one other hit,
_validate_discussions_to, where the return is deliberate: it suppresses the
catch-all error after a matching suffix. That one is left alone.
Five of these seven cases fail without the previous commit, because validation stopped at the first version without a micro part. The existing test_validate_python_version builds its expected messages from the whole line, so it can only describe single-version headers; this covers lists.
Dhairya-007
requested review from
AA-Turner,
CAM-Gerlach and
hugovk
as code owners
November 8, 2026 20:07
Documentation build overview
7 files changed ·
|
Contributor
Author
|
@StanFromIreland would you mind taking a look? This one is a |
Member
|
Duplicate of #5221. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_validate_python_versionloops over the comma-separated versions in aPython-Versionheader, but the "no micro part" branch usedreturninstead ofcontinue:The function is a generator, so
returnends the whole validation rather thanmoving on to the next version. Two-segment versions (
3.12,3.0) are theoverwhelming majority, so in practice only the first entry of a
Python-Versionheader was ever checked:All four are reported after the change. None of the checks were missing — they
were simply unreachable for every version after the first.
return→continueis the whole fix.Checks
python3 check-peps.pyover all PEPs still exits 0, so no currently committedPEP trips the newly reachable checks — this does not turn CI red.
test_validate_python_versionbuilds its expected messages fromthe whole line, so it can only describe single-version headers. I added
test_validate_python_version_all_versionsfor lists; five of its seven casesfail without the fix.
pytest pep_sphinx_extensions/tests/pep_lint/→ 469 passed, andblackandruffare clean on both files.One deliberate non-change
An AST sweep for
returninside a loop in a generator turns up one other hit,_validate_discussions_to. There thereturnis correct — it suppresses thecatch-all "must be a valid thread URL, mailing list, or 'Pending'" error once a
known suffix matches — so I left it alone.