From 49c161df13d8030bf803100b312c7989f83c9de4 Mon Sep 17 00:00:00 2001 From: Trim21 Date: Mon, 6 Jan 2025 03:19:40 +0800 Subject: [PATCH] fix sync command --- src/poetry/console/commands/install.py | 22 ++++++++++++---------- src/poetry/console/commands/sync.py | 3 +++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/poetry/console/commands/install.py b/src/poetry/console/commands/install.py index bedb292b587..bbd06b0268c 100644 --- a/src/poetry/console/commands/install.py +++ b/src/poetry/console/commands/install.py @@ -94,6 +94,18 @@ def _alternative_sync_command(self) -> str: return "poetry sync" def handle(self) -> int: + with_synchronization = self.option("sync") + if with_synchronization: + self.line_error( + "The `--sync` option is" + " deprecated and slated for removal in the next minor release" + " after June 2025, use the" + f" `{self._alternative_sync_command}`" + " command instead." + ) + return self._handle_install(with_synchronization) + + def _handle_install(self, with_synchronization: bool) -> int: from poetry.core.masonry.utils.module import ModuleOrPackageNotFoundError from poetry.masonry.builders.editable import EditableBuilder @@ -150,16 +162,6 @@ def handle(self) -> int: self.installer.extras(extras) - with_synchronization = self.option("sync") - if with_synchronization: - self.line_error( - "The `--sync` option is" - " deprecated and slated for removal in the next minor release" - " after June 2025, use the" - f" `{self._alternative_sync_command}`" - " command instead." - ) - self.installer.only_groups(self.activated_groups) self.installer.skip_directory(self.option("no-directory")) self.installer.dry_run(self.option("dry-run")) diff --git a/src/poetry/console/commands/sync.py b/src/poetry/console/commands/sync.py index 29d6c1be873..f6583d3cbd5 100644 --- a/src/poetry/console/commands/sync.py +++ b/src/poetry/console/commands/sync.py @@ -34,3 +34,6 @@ class SyncCommand(InstallCommand): If you want to use Poetry only for dependency management but not for packaging, you can set the "package-mode" to false in your pyproject.toml file. """ + + def handle(self) -> int: + return self._handle_install(True)