Skip to content

Commit

Permalink
sources: change future warning that PyPI will only be disabled automa…
Browse files Browse the repository at this point in the history
…tically if there are no primary sources (#8151)
  • Loading branch information
radoering authored Jul 4, 2023
1 parent d508c9f commit 79f2668
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/repositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ poetry source add --priority=default foo https://foo.bar/simple/
{{% warning %}}

In a future version of Poetry, PyPI will be disabled automatically
if there is at least one custom source configured with another priority than `explicit`.
if at least one custom primary source is configured.
If you are using custom sources in addition to PyPI, you should configure PyPI explicitly
with a certain priority, e.g.

Expand Down
6 changes: 3 additions & 3 deletions src/poetry/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ def create_pool(
else:
from poetry.repositories.pypi_repository import PyPiRepository

if pool.repositories:
if pool.has_primary_repositories():
io.write_error_line(
"<warning>"
"Warning: In a future version of Poetry, PyPI will be disabled"
" automatically if at least one custom source is configured"
" with another priority than 'explicit'. In order to avoid"
" automatically if at least one custom primary source is"
" configured. In order to avoid"
" a breaking change and make your pyproject.toml forward"
" compatible, add PyPI explicitly via 'poetry source add pypi'."
" By the way, this has the advantage that you can set the"
Expand Down
8 changes: 6 additions & 2 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ def test_poetry_with_no_default_source(fixture_dir: FixtureDirGetter) -> None:
def test_poetry_with_supplemental_source(
fixture_dir: FixtureDirGetter, with_simple_keyring: None
) -> None:
poetry = Factory().create_poetry(fixture_dir("with_supplemental_source"))
io = BufferedIO()
poetry = Factory().create_poetry(fixture_dir("with_supplemental_source"), io=io)

assert poetry.pool.has_repository("PyPI")
assert poetry.pool.get_priority("PyPI") is Priority.DEFAULT
Expand All @@ -429,12 +430,14 @@ def test_poetry_with_supplemental_source(
assert poetry.pool.get_priority("supplemental") is Priority.SUPPLEMENTAL
assert isinstance(poetry.pool.repository("supplemental"), LegacyRepository)
assert {repo.name for repo in poetry.pool.repositories} == {"PyPI", "supplemental"}
assert io.fetch_error() == ""


def test_poetry_with_explicit_source(
fixture_dir: FixtureDirGetter, with_simple_keyring: None
) -> None:
poetry = Factory().create_poetry(fixture_dir("with_explicit_source"))
io = BufferedIO()
poetry = Factory().create_poetry(fixture_dir("with_explicit_source"), io=io)

assert len(poetry.pool.repositories) == 1
assert len(poetry.pool.all_repositories) == 2
Expand All @@ -444,6 +447,7 @@ def test_poetry_with_explicit_source(
assert poetry.pool.has_repository("explicit")
assert isinstance(poetry.pool.repository("explicit"), LegacyRepository)
assert {repo.name for repo in poetry.pool.repositories} == {"PyPI"}
assert io.fetch_error() == ""


def test_poetry_with_explicit_pypi_and_other(
Expand Down

0 comments on commit 79f2668

Please sign in to comment.