fix: format_python_constraint IndexError on unions outside PYTHON_VERSION - #971
Open
otiscuilei wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. If the formatting is wrong, published package metadata could allow installation on an unsupported Python version or reject a supported one, and reverting would not change metadata already released. The impact is bounded to affected package artifacts and can be repaired with a subsequent release.
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.
format_python_constraintwalks a hardcodedPYTHON_VERSIONlist (currently through 3.14) and then takesaccepted[0]as the lower bound. AVersionUnionthat matches none of those series raisesIndexErrorwhile writing wheelRequires-Python.That path is used for legacy
[tool.poetry.dependencies] python = "…"(PEP 621requires-pythonbypasses the helper). Adjacent ranges such as~3.15 || ~3.16merge into a singleVersionRangeand are fine. Non-adjacent unions do not merge and crash:^3.15/>=3.15/~3.15are ranges and already work. Falling back tostr(union)would emit poetry||syntax, which is not valid PEP 440.When nothing in
PYTHON_VERSIONmatched, take the union's own lower bound and keep excluding the known series — the same approximation the helper already uses for in-list unions (3.8 || 3.10also allows later 3.x not in the list). This does not add 3.15 toPYTHON_VERSION(see #961).