Skip to content

Commit

Permalink
repository: according to PEP 440 pre-releases should be considered "i…
Browse files Browse the repository at this point in the history
…f the only available version that satisfies the version specifier is a pre-release" (no special handling of "*" constraint)
  • Loading branch information
radoering authored and neersighted committed Dec 21, 2022
1 parent cfdba43 commit 6e84663
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/poetry/repositories/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ def find_packages(self, dependency: Dependency) -> list[Package]:
and not allow_prereleases
and not package.is_direct_origin()
):
if constraint.is_any():
# we need this when all versions of the package are pre-releases
ignored_pre_release_packages.append(package)
ignored_pre_release_packages.append(package)
continue

packages.append(package)
Expand Down
9 changes: 1 addition & 8 deletions tests/repositories/test_legacy_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_find_packages_no_prereleases() -> None:


@pytest.mark.parametrize(
["constraint", "count"], [("*", 1), (">=1", 0), (">=19.0.0a0", 1)]
["constraint", "count"], [("*", 1), (">=1", 1), ("<=18", 0), (">=19.0.0a0", 1)]
)
def test_find_packages_only_prereleases(constraint: str, count: int) -> None:
repo = MockRepository()
Expand All @@ -228,13 +228,6 @@ def test_find_packages_only_prereleases(constraint: str, count: int) -> None:
assert package.source_url == repo.url


def test_find_packages_only_prereleases_empty_when_not_any() -> None:
repo = MockRepository()
packages = repo.find_packages(Factory.create_dependency("black", ">=1"))

assert len(packages) == 0


@pytest.mark.parametrize(
["constraint", "expected"],
[
Expand Down
2 changes: 1 addition & 1 deletion tests/repositories/test_pypi_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_find_packages_does_not_select_prereleases_if_not_allowed() -> None:


@pytest.mark.parametrize(
["constraint", "count"], [("*", 1), (">=1", 0), (">=19.0.0a0", 1)]
["constraint", "count"], [("*", 1), (">=1", 1), ("<=18", 0), (">=19.0.0a0", 1)]
)
def test_find_packages_only_prereleases(constraint: str, count: int) -> None:
repo = MockRepository()
Expand Down

0 comments on commit 6e84663

Please sign in to comment.