fix: Poetry single-component tilde constraint converts to an invalid specifier - #3852
Closed
VXNCXNX wants to merge 2 commits into
Closed
fix: Poetry single-component tilde constraint converts to an invalid specifier#3852VXNCXNX wants to merge 2 commits into
VXNCXNX wants to merge 2 commits into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3852 +/- ##
=======================================
Coverage 88.49% 88.49%
=======================================
Files 121 121
Lines 13276 13279 +3
Branches 2255 2256 +1
=======================================
+ Hits 11748 11751 +3
Misses 962 962
Partials 566 566
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
frostming
reviewed
Aug 18, 2026
| if "." not in ver: | ||
| # ``~=1`` is not a valid PEP 440 specifier, and Poetry's ``~1`` | ||
| # allows the minor version to change, so it means ``>=1,<2``. | ||
| parts.append(f">={ver},<{_caret_upper_bound(ver)}") |
Collaborator
There was a problem hiding this comment.
How about changing to ~=1.0, i think they are equivalent
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.
pdm import -f poetrycrashes on a single-component tilde constraint such asfoo = "~1". It is converted to~=1, which is not a valid PEP 440 specifier:Poetry defines
~1as>=1.0.0,<2.0.0, so the single-component case reuses_caret_upper_bound, which gives the same bound for this shape. Multi-component tilde keeps mapping to~=, so~2.5and~1.2.3are untouched.Follow-up to #3848, which fixed the caret branch and left this one. Test added in
tests/test_formats.py; removing the branch brings backInvalid specifier: '~=1'.tests/test_formats.pypasses apart fromtest_export_from_pylock_not_empty, which fails identically on an unmodified checkout. ruff check and format clean.AI disclosure: written with Claude Code. I ran
pdm importbefore and after and checked the mutation myself.