From 46d40f1d1746dff14692b11a707718c8e62ae7d3 Mon Sep 17 00:00:00 2001 From: SarthakB11 Date: Sun, 17 May 2026 18:37:25 +0000 Subject: [PATCH 1/2] fix(add): include pyproject.toml path in "already present" message Resolves #10179 --- src/poetry/console/commands/add.py | 4 ++-- tests/console/commands/test_add.py | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/poetry/console/commands/add.py b/src/poetry/console/commands/add.py index 28a2a7bc030..a517e587e39 100644 --- a/src/poetry/console/commands/add.py +++ b/src/poetry/console/commands/add.py @@ -443,8 +443,8 @@ def _hint_update_packages(self) -> str: def notify_about_existing_packages(self, existing_packages: list[str]) -> None: self.line( - "The following packages are already present in the pyproject.toml and will" - " be skipped:\n" + f"The following packages are already present in the pyproject.toml" + f" ({self.poetry.file.path}) and will be skipped:\n" ) for name in existing_packages: self.line(f" - {name}") diff --git a/tests/console/commands/test_add.py b/tests/console/commands/test_add.py index c6352854008..bf1390fd232 100644 --- a/tests/console/commands/test_add.py +++ b/tests/console/commands/test_add.py @@ -1416,8 +1416,9 @@ def test_add_should_skip_when_adding_existing_package_with_no_constraint( repo.add_package(get_package("foo", "1.1.2")) tester.execute("foo") - expected = """\ -The following packages are already present in the pyproject.toml and will be skipped: + expected = f"""\ +The following packages are already present in the pyproject.toml\ + ({app.poetry.file.path}) and will be skipped: - foo @@ -1447,8 +1448,9 @@ def test_add_should_skip_when_adding_canonicalized_existing_package_with_no_cons repo.add_package(get_package("foo-bar", "1.1.2")) tester.execute("Foo_Bar") - expected = """\ -The following packages are already present in the pyproject.toml and will be skipped: + expected = f"""\ +The following packages are already present in the pyproject.toml\ + ({app.poetry.file.path}) and will be skipped: - Foo_Bar From e44b5e755838ec51425d5d6e4bd0349c941bdb0d Mon Sep 17 00:00:00 2001 From: SarthakB11 Date: Sun, 17 May 2026 19:10:25 +0000 Subject: [PATCH 2/2] test(self/add): update plugin-add assertion to include pyproject.toml path Same message change as the main add command; this test was missed. --- tests/console/commands/self/test_add_plugins.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/console/commands/self/test_add_plugins.py b/tests/console/commands/self/test_add_plugins.py index 4e9786fd92d..8b447b5f4bc 100644 --- a/tests/console/commands/self/test_add_plugins.py +++ b/tests/console/commands/self/test_add_plugins.py @@ -203,8 +203,8 @@ def test_add_existing_plugin_warns_about_no_operation( assert isinstance(tester.command, AddCommand) expected = f"""\ -The following packages are already present in the pyproject.toml and will be\ - skipped: +The following packages are already present in the pyproject.toml\ + ({tester.command.poetry.file.path}) and will be skipped: - poetry-plugin {tester.command._hint_update_packages}