From 0c6808ba2700c6a446c40633ed81ee929174a649 Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Mon, 11 Apr 2022 00:32:30 +0200 Subject: [PATCH] locker: remove with_dev_reqs parameter This is no longer required and is superseded by the groups feature. --- src/poetry/console/commands/show.py | 2 +- src/poetry/installation/installer.py | 6 +++--- src/poetry/packages/locker.py | 13 +++---------- tests/console/commands/test_lock.py | 6 ++---- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/poetry/console/commands/show.py b/src/poetry/console/commands/show.py index d2557af1994..22e9b7b4f2c 100644 --- a/src/poetry/console/commands/show.py +++ b/src/poetry/console/commands/show.py @@ -75,7 +75,7 @@ def handle(self) -> int | None: ) return 1 - locked_repo = self.poetry.locker.locked_repository(True) + locked_repo = self.poetry.locker.locked_repository() root = self.project_with_activated_groups_only() # Show tree view if requested diff --git a/src/poetry/installation/installer.py b/src/poetry/installation/installer.py index de5216775a9..4a63e0767aa 100644 --- a/src/poetry/installation/installer.py +++ b/src/poetry/installation/installer.py @@ -190,7 +190,7 @@ def _do_refresh(self) -> int: if extra not in self._package.extras: raise ValueError(f"Extra [{extra}] is not specified.") - locked_repository = self._locker.locked_repository(True) + locked_repository = self._locker.locked_repository() solver = Solver( self._package, self._pool, @@ -214,7 +214,7 @@ def _do_install(self, local_repo: Repository) -> int: locked_repository = Repository() if self._update: if self._locker.is_locked() and not self._lock: - locked_repository = self._locker.locked_repository(True) + locked_repository = self._locker.locked_repository() # If no packages have been whitelisted (The ones we want to update), # we whitelist every package in the lock file. @@ -240,7 +240,7 @@ def _do_install(self, local_repo: Repository) -> int: else: self._io.write_line("Installing dependencies from lock file") - locked_repository = self._locker.locked_repository(True) + locked_repository = self._locker.locked_repository() if not self._locker.is_fresh(): self._io.write_error_line( diff --git a/src/poetry/packages/locker.py b/src/poetry/packages/locker.py index b35a7c6d6f5..80c24a4fb9f 100644 --- a/src/poetry/packages/locker.py +++ b/src/poetry/packages/locker.py @@ -86,7 +86,7 @@ def is_fresh(self) -> bool: return False - def locked_repository(self, with_dev_reqs: bool = False) -> Repository: + def locked_repository(self) -> Repository: """ Searches and returns a repository of locked packages. """ @@ -98,13 +98,7 @@ def locked_repository(self, with_dev_reqs: bool = False) -> Repository: lock_data = self.lock_data packages = Repository() - - if with_dev_reqs: - locked_packages = lock_data["package"] - else: - locked_packages = [ - p for p in lock_data["package"] if p["category"] == "main" - ] + locked_packages = lock_data["package"] if not locked_packages: return packages @@ -317,7 +311,6 @@ def get_project_dependency_packages( self, project_requires: list[Dependency], project_python_marker: BaseMarker | None = None, - dev: bool = False, extras: bool | Sequence[str] | None = None, ) -> Iterator[DependencyPackage]: # Apply the project python marker to all requirements. @@ -329,7 +322,7 @@ def get_project_dependency_packages( marked_requires.append(require) project_requires = marked_requires - repository = self.locked_repository(with_dev_reqs=dev) + repository = self.locked_repository() # Build a set of all packages required by our selected extras extra_package_names: set[str] | None = None diff --git a/tests/console/commands/test_lock.py b/tests/console/commands/test_lock.py index f12837d6bc3..dae977a1d27 100644 --- a/tests/console/commands/test_lock.py +++ b/tests/console/commands/test_lock.py @@ -129,9 +129,7 @@ def test_lock_no_update( ) poetry_with_old_lockfile.set_locker(locker) - locked_repository = poetry_with_old_lockfile.locker.locked_repository( - with_dev_reqs=True - ) + locked_repository = poetry_with_old_lockfile.locker.locked_repository() assert ( poetry_with_old_lockfile.locker.lock_data["metadata"].get("lock-version") == "1.0" @@ -144,7 +142,7 @@ def test_lock_no_update( lock=poetry_with_old_lockfile.pyproject.file.path.parent / "poetry.lock", local_config={}, ) - packages = locker.locked_repository(True).packages + packages = locker.locked_repository().packages assert len(packages) == len(locked_repository.packages)