fix(workspace): keep declared group for workspace members in lockfile - #3819
Conversation
Implicit workspace members were always injected into the default group with groups=["default"]. When a member was only declared in a dev/test group, lockfile metadata still listed default, which is wrong. Skip members already present in non-default groups when injecting implicit workspace deps, and associate the original requirement when resolving workspace candidates. Fixes pdm-project#3816
for more information, see https://pre-commit.ci
|
The tests are failed, please check @Solaris-star |
yangfan-yf-yf
left a comment
There was a problem hiding this comment.
I reproduced the two CI failures on f01a437 locally on Windows:
py -m uv run pytest tests/cli/test_add.py::test_add_subdirectory_path_updates_workspace tests/test_project.py::test_workspace_member_declared_in_dev_group_not_forced_into_default -q
# 2 failedThe first failure is a regression from can.copy_with(original_req): the workspace candidate used by pdm add packages/foo is no longer editable. The same existing test passes on the current main branch, so the workspace candidate needs to retain its editable requirement while still carrying the declared dependency's group information.
The new test also calls project.get_dependencies(default). That resolves only the default group, so declared_elsewhere never sees the test dependency and the implicit workspace member is expected to be added. Please exercise the all-group lock-resolution path (or otherwise include the declared group in the resolution) when checking the lockfile group result.
Signed-off-by: Solaris-star <820622658@qq.com>
|
Thanks for the precise repro. I pushed |
# Conflicts: # src/pdm/project/core.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3819 +/- ##
=======================================
Coverage 86.39% 86.39%
=======================================
Files 121 121
Lines 13224 13227 +3
Branches 2244 2245 +1
=======================================
+ Hits 11425 11428 +3
Misses 1185 1185
Partials 614 614
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:
|
Description
Workspace members are always injected as implicit editable dependencies with
groups = ["default"]. When a member is only declared in a non-default group (e.g.pdm add -dG test ./subproject), the lockfile still marked it asdefault(and sometimes bothdefaultandtest).Removing the workspace config made groups correct, so the bug is specifically the implicit default injection path.
Fix
with_workspace_dependencies(..., exclude=...)— skip members already declared in other groups when injecting intodefault._resolve_dependencies— computedeclared_elsewhereand pass it asexclude.find_matches—copy_with(original_req)for workspace candidates so requirement groups follow the declared dependency.Verification
Minimal workspace repro (
pdm add -dG test ./subproject):Linked Issue
Closes #3816