From b701921779f532eae909e181c675bac2d71023b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Sun, 13 Aug 2023 17:52:30 +0200 Subject: [PATCH] be nice to plugin authors --- src/poetry/repositories/repository_pool.py | 12 ++++++++++++ tests/repositories/test_repository_pool.py | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/poetry/repositories/repository_pool.py b/src/poetry/repositories/repository_pool.py index c1dd7ccb9a4..9d6338f4ff2 100644 --- a/src/poetry/repositories/repository_pool.py +++ b/src/poetry/repositories/repository_pool.py @@ -20,6 +20,8 @@ from poetry.core.packages.dependency import Dependency from poetry.core.packages.package import Package +_SENTINEL = object() + class Priority(IntEnum): # The order of the members below dictates the actual priority. The first member has @@ -41,6 +43,7 @@ class RepositoryPool(AbstractRepository): def __init__( self, repositories: list[Repository] | None = None, + ignore_repository_names: object = _SENTINEL, *, config: Config | None = None, ) -> None: @@ -56,6 +59,15 @@ def __init__( cache_dir=(config or Config.create()).artifacts_cache_directory ) + if ignore_repository_names is not _SENTINEL: + warnings.warn( + "The 'ignore_repository_names' argument to 'RepositoryPool.__init__' is" + " deprecated. It has no effect anymore and will be removed in a future" + " version.", + DeprecationWarning, + stacklevel=2, + ) + @staticmethod def from_packages(packages: list[Package], config: Config | None) -> RepositoryPool: pool = RepositoryPool(config=config) diff --git a/tests/repositories/test_repository_pool.py b/tests/repositories/test_repository_pool.py index 9ec5f68401e..2a62f360815 100644 --- a/tests/repositories/test_repository_pool.py +++ b/tests/repositories/test_repository_pool.py @@ -38,6 +38,17 @@ def test_repository_no_repository() -> None: pool.repository("foo") +def test_repository_deprecated_ignore_repository_names() -> None: + with pytest.warns(DeprecationWarning): + RepositoryPool(ignore_repository_names=True) + with pytest.warns(DeprecationWarning): + RepositoryPool(ignore_repository_names=False) + with pytest.warns(DeprecationWarning): + RepositoryPool(None, True) + with pytest.warns(DeprecationWarning): + RepositoryPool(None, False) + + def test_adding_repositories_with_same_name_twice_raises_value_error() -> None: repo1 = Repository("repo") repo2 = Repository("repo")