From ae3cb779bb29fbb965e648aa829ff12b06e93e9a Mon Sep 17 00:00:00 2001 From: pratyushsinghal7 Date: Thu, 23 Jul 2026 22:12:40 -0700 Subject: [PATCH 1/2] Skip plugin loading for version output --- src/poetry/console/application.py | 4 +++- tests/console/test_application.py | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/poetry/console/application.py b/src/poetry/console/application.py index d6d41383cf6..fd72a30a312 100644 --- a/src/poetry/console/application.py +++ b/src/poetry/console/application.py @@ -632,7 +632,9 @@ def _load_plugins(self, io: IO) -> None: if self._plugins_loaded: return - self._disable_plugins = io.input.has_parameter_option("--no-plugins") + self._disable_plugins = io.input.has_parameter_option( + "--no-plugins" + ) or io.input.has_parameter_option(["--version", "-V"], only_params=True) if not self._disable_plugins: from poetry.plugins.application_plugin import ApplicationPlugin diff --git a/tests/console/test_application.py b/tests/console/test_application.py index 2fc8546bb3c..35fa70d5372 100644 --- a/tests/console/test_application.py +++ b/tests/console/test_application.py @@ -14,6 +14,7 @@ from poetry.console.application import Application from poetry.console.commands.command import Command from poetry.plugins.application_plugin import ApplicationPlugin +from poetry.plugins.plugin_manager import PluginManager from poetry.plugins.plugin_manager import ProjectPluginCache from poetry.repositories.cached_repository import CachedRepository from poetry.utils.authenticator import Authenticator @@ -73,6 +74,28 @@ def test_application_with_plugins_disabled(with_add_command_plugin: None) -> Non assert tester.status_code == 0 +@pytest.mark.parametrize("version_option", ["--version", "-V"]) +def test_application_version_does_not_load_plugins( + version_option: str, mocker: MockerFixture +) -> None: + load_plugins = mocker.spy(PluginManager, "load_plugins") + tester = ApplicationTester(Application()) + + tester.execute(version_option) + + load_plugins.assert_not_called() + assert tester.status_code == 0 + + +def test_application_subcommand_version_loads_plugins(mocker: MockerFixture) -> None: + load_plugins = mocker.spy(PluginManager, "load_plugins") + tester = ApplicationTester(Application()) + + tester.execute("run -- python -V") + + load_plugins.assert_called_once() + + def test_application_execute_plugin_command(with_add_command_plugin: None) -> None: app = Application() From c98e96c06d51f170411a205e29a3b9365f409cec Mon Sep 17 00:00:00 2001 From: pratyushsinghal7 Date: Fri, 24 Jul 2026 11:58:37 -0700 Subject: [PATCH 2/2] test: cover delimiter-free run version argument --- tests/console/test_application.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/console/test_application.py b/tests/console/test_application.py index 35fa70d5372..f0e380e482e 100644 --- a/tests/console/test_application.py +++ b/tests/console/test_application.py @@ -87,11 +87,14 @@ def test_application_version_does_not_load_plugins( assert tester.status_code == 0 -def test_application_subcommand_version_loads_plugins(mocker: MockerFixture) -> None: +@pytest.mark.parametrize("command", ["run python -V", "run -- python -V"]) +def test_application_subcommand_version_loads_plugins( + command: str, mocker: MockerFixture +) -> None: load_plugins = mocker.spy(PluginManager, "load_plugins") tester = ApplicationTester(Application()) - tester.execute("run -- python -V") + tester.execute(command) load_plugins.assert_called_once()