From dfe885044e14fc118942a7bcb489d052295a734f Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sun, 4 Sep 2022 10:42:15 +0100 Subject: [PATCH] direct URL dependencies are never outdated --- src/poetry/console/commands/show.py | 2 +- src/poetry/installation/pip_installer.py | 5 +-- src/poetry/puzzle/provider.py | 11 ++--- tests/console/commands/test_show.py | 51 ++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/poetry/console/commands/show.py b/src/poetry/console/commands/show.py index b80d8c51edb..f773ce33fff 100644 --- a/src/poetry/console/commands/show.py +++ b/src/poetry/console/commands/show.py @@ -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: diff --git a/src/poetry/installation/pip_installer.py b/src/poetry/installation/pip_installer.py index 34a7620cce6..dcb6229db16 100644 --- a/src/poetry/installation/pip_installer.py +++ b/src/poetry/installation/pip_installer.py @@ -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) diff --git a/src/poetry/puzzle/provider.py b/src/poetry/puzzle/provider.py index 523228c9e88..898ace3538c 100644 --- a/src/poetry/puzzle/provider.py +++ b/src/poetry/puzzle/provider.py @@ -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, @@ -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 diff --git a/tests/console/commands/test_show.py b/tests/console/commands/test_show.py index 839c7d76055..3d6d60a477b 100644 --- a/tests/console/commands/test_show.py +++ b/tests/console/commands/test_show.py @@ -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() == ""