From aaeb67d752e7206e546b055e9e51dff5ed4301ee Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sat, 11 Nov 2023 13:42:01 +0000 Subject: [PATCH] Complete the removal of poetry-export This reverts commit f59728d74b1252a0105ce5b8062f8fa28535084f. --- docs/cli.md | 12 ++--------- docs/pre-commit-hooks.md | 4 ---- src/poetry/config/config.py | 4 ---- src/poetry/console/application.py | 6 ------ src/poetry/console/commands/config.py | 1 - src/poetry/console/commands/export.py | 21 ------------------ tests/console/commands/test_config.py | 6 ------ tests/console/commands/test_export.py | 31 --------------------------- 8 files changed, 2 insertions(+), 83 deletions(-) delete mode 100644 src/poetry/console/commands/export.py delete mode 100644 tests/console/commands/test_export.py diff --git a/docs/cli.md b/docs/cli.md index 787a1afd01f..7e4eaf4a142 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -720,17 +720,9 @@ This command exports the lock file to other formats. poetry export -f requirements.txt --output requirements.txt ``` -{{% warning %}} -This command is provided by the [Export Poetry Plugin](https://github.com/python-poetry/poetry-plugin-export). -In a future version of Poetry this plugin will not be installed by default anymore. -In order to avoid a breaking change and make your automation forward-compatible, -please install poetry-plugin-export explicitly. -See [Using plugins]({{< relref "plugins#using-plugins" >}}) for details on how to install a plugin. -{{% /warning %}} - {{% note %}} -This command is also available as a pre-commit hook. -See [pre-commit hooks]({{< relref "pre-commit-hooks#poetry-export" >}}) for more information. +This command is provided by the [Export Poetry Plugin](https://github.com/python-poetry/poetry-plugin-export) +and is also available as a pre-commit hook. See [pre-commit hooks]({{< relref "pre-commit-hooks#poetry-export" >}}) for more information. {{% /note %}} {{% note %}} diff --git a/docs/pre-commit-hooks.md b/docs/pre-commit-hooks.md index 7989386a554..2a718cd8197 100644 --- a/docs/pre-commit-hooks.md +++ b/docs/pre-commit-hooks.md @@ -53,10 +53,6 @@ For more information see the [lock command]({{< relref "cli#lock" >}}). The `poetry-export` hook calls the `poetry export` command to sync your `requirements.txt` file with your current dependencies. -{{% warning %}} -This hook is provided by the [Export Poetry Plugin](https://github.com/python-poetry/poetry-plugin-export). -{{% /warning %}} - {{% note %}} This hook is provided by the [Export Poetry Plugin](https://github.com/python-poetry/poetry-plugin-export). diff --git a/src/poetry/config/config.py b/src/poetry/config/config.py index cbd89ebf614..2c7409a07fb 100644 --- a/src/poetry/config/config.py +++ b/src/poetry/config/config.py @@ -133,9 +133,6 @@ class Config: "max-workers": None, "no-binary": None, }, - "warnings": { - "export": True, - }, } def __init__( @@ -298,7 +295,6 @@ def _get_normalizer(name: str) -> Callable[[str], Any]: "experimental.system-git-client", "installer.modern-installation", "installer.parallel", - "warnings.export", }: return boolean_normalizer diff --git a/src/poetry/console/application.py b/src/poetry/console/application.py index 3286c73f80b..5427bd16e7c 100644 --- a/src/poetry/console/application.py +++ b/src/poetry/console/application.py @@ -354,12 +354,6 @@ def _load_plugins(self, io: IO | None = None) -> None: manager.load_plugins() manager.activate(self) - # We have to override the command from poetry-plugin-export - # with the wrapper. - if self.command_loader.has("export"): - del self.command_loader._factories["export"] - self.command_loader._factories["export"] = load_command("export") - self._plugins_loaded = True @property diff --git a/src/poetry/console/commands/config.py b/src/poetry/console/commands/config.py index 3b460fb7aa2..008817918d5 100644 --- a/src/poetry/console/commands/config.py +++ b/src/poetry/console/commands/config.py @@ -77,7 +77,6 @@ def unique_config_values(self) -> dict[str, tuple[Any, Any]]: PackageFilterPolicy.validator, PackageFilterPolicy.normalize, ), - "warnings.export": (boolean_validator, boolean_normalizer), } return unique_config_values diff --git a/src/poetry/console/commands/export.py b/src/poetry/console/commands/export.py deleted file mode 100644 index cf18e279deb..00000000000 --- a/src/poetry/console/commands/export.py +++ /dev/null @@ -1,21 +0,0 @@ -from __future__ import annotations - -from poetry_plugin_export.command import ( # type: ignore[import-untyped] - ExportCommand as BaseExportCommand, -) - - -class ExportCommand(BaseExportCommand): # type: ignore[misc] - def handle(self) -> int: - if self.poetry.config.get("warnings.export"): - self.line_error( - "Warning: poetry-plugin-export will not be installed by default in a" - " future version of Poetry.\n" - "In order to avoid a breaking change and make your automation" - " forward-compatible, please install poetry-plugin-export explicitly." - " See https://python-poetry.org/docs/plugins/#using-plugins for details" - " on how to install a plugin.\n" - "To disable this warning run 'poetry config warnings.export false'.", - style="warning", - ) - return super().handle() # type: ignore[no-any-return] diff --git a/tests/console/commands/test_config.py b/tests/console/commands/test_config.py index 24b89a63d9b..1f22b958e0a 100644 --- a/tests/console/commands/test_config.py +++ b/tests/console/commands/test_config.py @@ -67,7 +67,6 @@ def test_list_displays_default_value_if_not_set( virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'} virtualenvs.prefer-active-python = false virtualenvs.prompt = "{{project_name}}-py{{python_version}}" -warnings.export = true """ assert tester.io.fetch_output() == expected @@ -97,7 +96,6 @@ def test_list_displays_set_get_setting( virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'} virtualenvs.prefer-active-python = false virtualenvs.prompt = "{{project_name}}-py{{python_version}}" -warnings.export = true """ assert config.set_config_source.call_count == 0 # type: ignore[attr-defined] @@ -148,7 +146,6 @@ def test_unset_setting( virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'} virtualenvs.prefer-active-python = false virtualenvs.prompt = "{{project_name}}-py{{python_version}}" -warnings.export = true """ assert config.set_config_source.call_count == 0 # type: ignore[attr-defined] assert tester.io.fetch_output() == expected @@ -177,7 +174,6 @@ def test_unset_repo_setting( virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'} virtualenvs.prefer-active-python = false virtualenvs.prompt = "{{project_name}}-py{{python_version}}" -warnings.export = true """ assert config.set_config_source.call_count == 0 # type: ignore[attr-defined] assert tester.io.fetch_output() == expected @@ -305,7 +301,6 @@ def test_list_displays_set_get_local_setting( virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'} virtualenvs.prefer-active-python = false virtualenvs.prompt = "{{project_name}}-py{{python_version}}" -warnings.export = true """ assert config.set_config_source.call_count == 1 # type: ignore[attr-defined] @@ -343,7 +338,6 @@ def test_list_must_not_display_sources_from_pyproject_toml( virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'} virtualenvs.prefer-active-python = false virtualenvs.prompt = "{{project_name}}-py{{python_version}}" -warnings.export = true """ assert tester.io.fetch_output() == expected diff --git a/tests/console/commands/test_export.py b/tests/console/commands/test_export.py deleted file mode 100644 index 962c2c8c151..00000000000 --- a/tests/console/commands/test_export.py +++ /dev/null @@ -1,31 +0,0 @@ -from __future__ import annotations - -from typing import TYPE_CHECKING - -import pytest - - -if TYPE_CHECKING: - from cleo.testers.command_tester import CommandTester - - from tests.conftest import Config - from tests.types import CommandTesterFactory - - -@pytest.fixture -def tester(command_tester_factory: CommandTesterFactory) -> CommandTester: - return command_tester_factory("export") - - -def test_export_prints_warning(tester: CommandTester) -> None: - tester.execute("") - assert ( - "Warning: poetry-plugin-export will not be installed by default" - in tester.io.fetch_error() - ) - - -def test_disable_export_warning(tester: CommandTester, config: Config) -> None: - config.config["warnings"]["export"] = False - tester.execute("") - assert "poetry-plugin-export" not in tester.io.fetch_error()