fix: uv cannot lock a project that declares no name or version - #3849
Merged
Conversation
uv requires project.name and project.version, while PDM allows an application to omit both. The generated pyproject.toml omitted them too, so uv failed to parse it. A placeholder is written instead, and the resulting root entry is filtered out again when the lockfile is read back so it never reaches pdm.lock. Fixes pdm-project#3421
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3849 +/- ##
==========================================
+ Coverage 88.41% 88.47% +0.06%
==========================================
Files 121 121
Lines 13258 13270 +12
Branches 2252 2253 +1
==========================================
+ Hits 11722 11741 +19
+ Misses 966 963 -3
+ Partials 570 566 -4
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:
|
tests/resolver/test_uv_resolver.py is marked network at module level, so the test was deselected in CI and the resolver change stayed uncovered. It reads a uv.lock from disk and needs no network.
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
With
use_uvenabled, a project that declares noproject.namecannot be locked or installed. uv requiresnameandversion, PDM allows an application to omit both, and thepyproject.tomlPDM generates for uv omits them too.Fixes #3421
Repro
A
pyproject.tomlwith a description and dependencies but no name or version:The fix
Write a placeholder name and version into the generated file, then filter that root entry out again when the uv lockfile is read back, so it never reaches
pdm.lock. The version is only filled when it is not declared dynamic, otherwise a dynamic version would be overwritten.Verification
Two tests, one per half of the fix. Removing the name fill fails the first, dropping the dynamic-version guard fails the second.
I ran the real commands rather than only the unit tests:
pdm lockandpdm installagainst a real uv, andgrepconfirms the placeholder does not appear in the generatedpdm.lock. A named project and a project with a dynamic version both still lock unchanged.Suite: 1340 passed. Two failures,
test_run_script_with_inline_metadataandtest_export_from_pylock_not_empty, are identical on a clean checkout here.ruff checkandruff format --checkclean on the touched files.