fix: Poetry caret on a 0.x version converts to the wrong upper bound - #3848
Merged
Merged
Conversation
A caret requirement allows changes that do not modify the leftmost non-zero component, so ^0.2.3 means <0.3.0 and ^0.0.3 means <0.0.4. The importer always bumped the major, widening both to <1.0.0 and letting an import pull in a breaking release.
|
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 #3848 +/- ##
==========================================
+ Coverage 88.41% 88.43% +0.01%
==========================================
Files 121 121
Lines 13258 13262 +4
Branches 2252 2252
==========================================
+ Hits 11722 11728 +6
+ Misses 966 965 -1
+ Partials 570 569 -1
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
approved these changes
Aug 17, 2026
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.
What's broken
pdm import -f poetryconverts every caret constraint by bumping the major component, so a0.xcaret gets a far wider bound than Poetry means. The imported project then accepts releases Poetry would have refused.Repro
attrs = "^0.2.3",tinylib = "^0.0.3",requests = "^2.28.1"in a Poetry project:The fix
A caret allows changes that do not modify the leftmost non-zero component, so the bumped position depends on where that component is.
_caret_upper_boundfinds it instead of assuming the major.Verification
test_convert_poetry_caret_constraintis parametrised over all seven rows of Poetry's own caret table,^1.2.3through^0, checked against the table in their dependency-specification docs. Forcing the index back to 0 fails three of them with assertion errors.Two assertions in
test_convert_poetryhad the old bounds baked in,cleo<1.0.0for^0.7.6andcachecontrol<1.0.0for^0.12.4. Both fixture constraints are0.x, so those were asserting the bug; they now read<0.8.0and<0.13.0.tests/test_formats.pypasses, 53 tests. The wider run has one failure,test_create_venv_in_project[venv-True], identical on a clean checkout here because this box has noensurepip.ruff checkandruff format --checkclean.