Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

direct URL dependencies are never outdated #6396

Merged
merged 1 commit into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
51 changes: 51 additions & 0 deletions tests/console/commands/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -1992,3 +1992,54 @@ 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() == ""