Skip to content

Commit

Permalink
direct URL dependencies are never outdated
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Sep 4, 2022
1 parent 5997a60 commit c90cdf6
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 13 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 @@ -502,7 +502,7 @@ def find_latest_package(
from poetry.version.version_selector import VersionSelector

# find the latest version allowed in this pool
if package.source_type in ("git", "file", "directory"):
if package.is_direct_origin():
requires = root.all_requires

for dep in requires:
Expand Down
5 changes: 1 addition & 4 deletions src/poetry/installation/pip_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ def install(self, package: Package, update: bool = False) -> None:

args = ["install", "--no-deps"]

if (
package.source_type not in {"git", "directory", "file", "url"}
and package.source_url
):
if not package.is_direct_origin() and package.source_url:
assert package.source_reference is not None
repository = self._pool.repository(package.source_reference)
parsed = urllib.parse.urlparse(package.source_url)
Expand Down
11 changes: 3 additions & 8 deletions src/poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,9 @@ def complete_package(
package = dependency_package.package
dependency = dependency_package.dependency
requires = package.all_requires
elif package.source_type not in {
"directory",
"file",
"url",
"git",
}:
elif package.is_direct_origin():
requires = package.requires
else:
try:
dependency_package = DependencyPackage(
dependency,
Expand All @@ -574,8 +571,6 @@ def complete_package(
package = dependency_package.package
dependency = dependency_package.dependency
requires = package.requires
else:
requires = package.requires

if self._load_deferred:
# Retrieving constraints for deferred dependencies
Expand Down
52 changes: 52 additions & 0 deletions tests/console/commands/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -1992,3 +1992,55 @@ def test_show_dependency_installed_from_git_in_dev(
# packages.
tester.execute("--outdated")
assert tester.io.fetch_output() == ""


def test_url_dependency_is_not_outdated_by_repository_package(
tester: CommandTester,
poetry: Poetry,
installed: Repository,
repo: TestRepository,
):
demo_url = "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl"
poetry.package.add_dependency(
Factory.create_dependency(
"demo",
{"url": demo_url},
)
)

# A newer version of demo is available in the repository.
demo_100 = get_package("demo", "1.0.0")
repo.add_package(demo_100)

poetry.locker.mock_lock_data(
{
"package": [
{
"name": "demo",
"version": "0.1.0",
"description": "Demo package",
"category": "main",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
"source": {
"type": "url",
"url": demo_url,
},
}
],
"metadata": {
"python-versions": "*",
"platform": "*",
"content-hash": "123456789",
"hashes": {"demo": []},
},
}
)

# The url dependency on demo is not made outdated by the existence of a newer
# version
# in the repository.
tester.execute("--outdated")
assert tester.io.fetch_output() == ""

0 comments on commit c90cdf6

Please sign in to comment.