Skip to content

Commit

Permalink
be nice to plugin authors
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering committed Aug 13, 2023
1 parent 5fc1a10 commit b701921
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/poetry/repositories/repository_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions tests/repositories/test_repository_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit b701921

Please sign in to comment.