Skip to content

Commit

Permalink
disambiguate direct dependencies in show-outdated
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Aug 25, 2022
1 parent 4392bd6 commit 38936d8
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/poetry/console/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def find_latest_package(
requires = root.all_requires

for dep in requires:
if dep.name == package.name:
if dep.name == package.name and dep.source_type == package.source_type:
provider = Provider(root, self.poetry.pool, NullIO())
return provider.search_for_direct_origin_dependency(dep)

Expand Down
2 changes: 1 addition & 1 deletion src/poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def search_for_direct_origin_dependency(self, dependency: Dependency) -> Package

else:
raise RuntimeError(
f"Unknown direct dependency type {dependency.source_type}"
f"{dependency}: unknown direct dependency type {dependency.source_type}"
)

if dependency.is_vcs():
Expand Down
68 changes: 68 additions & 0 deletions tests/console/commands/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -1924,3 +1924,71 @@ def test_show_errors_without_lock_file(tester: CommandTester, poetry: Poetry):
expected = "Error: poetry.lock not found. Run `poetry lock` to create it.\n"
assert tester.io.fetch_error() == expected
assert tester.status_code == 1


def test_show_dependency_installed_from_git_in_dev(
tester: CommandTester,
poetry: Poetry,
installed: Repository,
repo: TestRepository,
):
# Add a regular dependency for a package in main, and a git dependency for the same
# package in dev.
poetry.package.add_dependency(Factory.create_dependency("demo", "^0.1.1"))
poetry.package.add_dependency(
Factory.create_dependency(
"demo", {"git": "https://github.com/demo/demo.git"}, groups=["dev"]
)
)

demo_011 = get_package("demo", "0.1.1")
demo_011.description = "Demo package"
repo.add_package(demo_011)

pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package"
repo.add_package(pendulum_200)

# The git package is the one that gets into the lockfile.
poetry.locker.mock_lock_data(
{
"package": [
{
"name": "demo",
"version": "0.1.2",
"description": "Demo package",
"category": "main",
"optional": False,
"python-versions": "*",
"develop": False,
"source": {
"type": "git",
"reference": MOCK_DEFAULT_GIT_REVISION,
"resolved_reference": MOCK_DEFAULT_GIT_REVISION,
"url": "https://github.com/demo/demo.git",
},
},
{
"name": "pendulum",
"version": "2.0.0",
"description": "Pendulum package",
"category": "main",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
},
],
"metadata": {
"python-versions": "*",
"platform": "*",
"content-hash": "123456789",
"hashes": {"demo": [], "pendulum": []},
},
}
)

# Nothing needs updating, there is no confusion between the git and not-git
# packages.
tester.execute("--outdated")
assert tester.io.fetch_output() == ""

0 comments on commit 38936d8

Please sign in to comment.