Repository navigation
Conversation
A two-segment value such as python_full_version ~= "3.8" was padded to "3.8.0", which turned >=3.8,==3.* into >=3.8.0,==3.8.*.
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/poetry/core/version/markers.py" line_range="453" />
<code_context>
+ name == "python_full_version"
+ and not swapped_name_value
+ # the precision of a compatible release clause is significant
+ and self._operator != "~="
+ ):
# fix precision of python_full_version marker
</code_context>
<issue_to_address>
**One-segment markers export invalidly**
When a dependency uses `python_full_version ~= "3"`, `SingleMarker` preserves `python_full_version ~= "3"`, and the version parser accepts it as a range when the release has fewer than two parts. The resulting marker violates PEP 440’s minimum precision for `~=`, so downstream packaging tools reject it when evaluating the exported marker.
Reject one-segment compatible-release markers, or otherwise ensure they are emitted in a valid PEP 440 form.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: src/poetry/core/version/markers.py:453
| name == "python_full_version" | ||
| and not swapped_name_value | ||
| # the precision of a compatible release clause is significant | ||
| and self._operator != "~=" |
There was a problem hiding this comment.
🟡 Medium · One-segment markers export invalidly
When a dependency uses python_full_version ~= "3", SingleMarker preserves python_full_version ~= "3", and the version parser accepts it as a range when the release has fewer than two parts. The resulting marker violates PEP 440’s minimum precision for ~=, so downstream packaging tools reject it when evaluating the exported marker.
Reject one-segment compatible-release markers, or otherwise ensure they are emitted in a valid PEP 440 form.
Prompt for AI agents
In `src/poetry/core/version/markers.py` at line 453:
**One-segment markers export invalidly**
When a dependency uses `python_full_version ~= "3"`, `SingleMarker` preserves `python_full_version ~= "3"`, and the version parser accepts it as a range when the release has fewer than two parts. The resulting marker violates PEP 440’s minimum precision for `~=`, so downstream packaging tools reject it when evaluating the exported marker.
Reject one-segment compatible-release markers, or otherwise ensure they are emitted in a valid PEP 440 form.This branch has not been deployed
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.
A
python_full_versionmarker with fewer than three segments is padded to three ("3.8"becomes"3.8.0"). That is fine for==,>=and friends, but for the compatible release operator the number of segments decides the upper bound:~= "3.8"means>= 3.8, == 3.*~= "3.8.0"means>= 3.8.0, == 3.8.*The same marker on a dependency (
Dependency.create_from_pep_508('foo; python_full_version ~= "3.8"')) is rewritten to~= "3.8.0", so the marker that ends up inpoetry.lockand in exported requirements excludes Python 3.9 and later.This also changes what gets locked and installed. With released poetry and
requires-python = ">=3.10",poetry lockleaves such a dependency out ofpoetry.lockentirely. Withrequires-python = ">=3.8"it is locked as~= "3.8.0", andpoetry installon Python 3.13 skips it.When a
python_full_versionmarker is merged with apython_versionmarker, the result goes through the same padding, e.g.python_full_version ~= "3.9" and python_version > "3.8"becamepython_full_version ~= "3.9.0"(False on 3.10.1, while the original is True). The padding is now skipped for~=there too.Tests added in
tests/version/test_markers.py; the second one covers the merge path.The implementation and tests were written with AI assistance.