Skip to content

Commit

Permalink
fix: missing deps when adding dev dependencies (#3361)
Browse files Browse the repository at this point in the history
* fix: missing deps when adding dev dependencies

Signed-off-by: Frost Ming <me@frostming.com>

* add news

Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming authored Dec 30, 2024
1 parent e4eb940 commit e29740f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/3361.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a problem of missing dependencies when adding to dev dependencies if both editable and non-editable dependencies exist.
3 changes: 2 additions & 1 deletion src/pdm/project/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,8 @@ def update_dev_dependencies(deps: list[str]) -> None:
if group == "default":
return metadata.get("dependencies", tomlkit.array()), lambda x: metadata.__setitem__("dependencies", x)
dev_dependencies = self.pyproject._data.get("dependency-groups", {})
dev_dependencies.update(self.pyproject.settings.get("dev-dependencies", {}))
for group, items in self.pyproject.settings.get("dev-dependencies", {}).items():
dev_dependencies.setdefault(group, []).extend(items)
deps_setter = [
(
metadata.get("optional-dependencies", {}),
Expand Down
13 changes: 13 additions & 0 deletions tests/cli/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ def test_non_editable_override_editable(project, pdm):
assert not project.get_dependencies("dev")[0].editable


@pytest.mark.usefixtures("working_set", "vcs")
def test_add_editable_normal_dev_dependency(project, pdm):
project.environment.python_requires = PySpecSet(">=3.6")
url = "git+https://github.com/test-root/demo.git#egg=demo"
pdm(["add", "--dev", "-e", url], obj=project, strict=True)
pdm(["add", "-d", "urllib3"], obj=project, strict=True)
pdm(["add", "-d", "idna"], obj=project, strict=True)
dev_group = project.pyproject.settings["dev-dependencies"]["dev"]
pep735_group = project.pyproject.dependency_groups["dev"]
assert dev_group == ["-e git+https://github.com/test-root/demo.git#egg=demo"]
assert pep735_group == ["urllib3>=1.22", "idna>=2.7"]


@pytest.mark.usefixtures("working_set")
def test_add_remote_package_url(project, dev_option, pdm):
project.environment.python_requires = PySpecSet(">=3.6")
Expand Down

0 comments on commit e29740f

Please sign in to comment.