add --dev --group test
ignores dev
if empty group with that name already exists in optional-dependencies
#3133
Labels
🐛 bug
Something isn't working
Steps to reproduce
Tl;DR
If a package has previously been added as an optional dependency, and then removed and re-added as a dev dependency with the same group name (which is currently empty), then it gets added back to
optional-dependencies
instead ofdev-dependencies
.Create a new project with
pdm init
, accept defaults.First add
pytest
(for example) as a test dependency:pdm add --group test pytest
. pyproject.toml will now have this:At this point the user (me) realises that instead it should be a dev-only dependency, so I do:
pdm remove -v --group test pytest
. Resulting section in pyproject.toml is still have the empty group 'test':Now, I add it as a
dev
dependency usingpdm add -v --dev --group test pytest
but in pyproj it's added back to the old section with the pre-existing group 'test':Remove it again from the group using similar-but-not-same command as Ste 3:
pdm remove -v --dev --group test pytest
and also fully delete the section[project.optional-dependencies]
inpyproject.toml
Again, add it as a
dev
dependency usingpdm add -v --dev --group test pytest
- exactly the same command as in step 4.Actual behavior
(Step 4 above.)
Expected behavior
(Step 6 above.) ➕
The documentation states:
Potential fixes:
*-dependencies
to allow moving packages & groups between optional & dev deps.pyproject.toml
- which is fine if they realised that was the cause.Environment Information
The text was updated successfully, but these errors were encountered: