Skip to content

Commit

Permalink
dependency: do not implicitly allow prereleases since this is not PEP…
Browse files Browse the repository at this point in the history
… 440 compliant and counterproductive (If only a prerelease fulfills a constraint, we choose it anyway. If a stable release fulfills a constraint, we shouldn't choose a prerelease if not explicitly requested.)
  • Loading branch information
radoering committed Jan 2, 2023
1 parent c12ff58 commit 1e6e668
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 27 deletions.
10 changes: 0 additions & 10 deletions src/poetry/core/packages/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from packaging.utils import canonicalize_name

from poetry.core.constraints.generic import parse_constraint as parse_generic_constraint
from poetry.core.constraints.version import VersionRangeConstraint
from poetry.core.constraints.version import parse_constraint
from poetry.core.packages.dependency_group import MAIN_GROUP
from poetry.core.packages.specification import PackageSpecification
Expand Down Expand Up @@ -71,15 +70,6 @@ def __init__(
groups = [MAIN_GROUP]

self._groups = frozenset(groups)

if (
isinstance(self._constraint, VersionRangeConstraint)
and self._constraint.min
):
allows_prereleases = (
allows_prereleases or self._constraint.min.is_unstable()
)

self._allows_prereleases = allows_prereleases

self._python_versions = "*"
Expand Down
17 changes: 0 additions & 17 deletions tests/packages/test_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,6 @@
from poetry.core.version.markers import parse_marker


@pytest.mark.parametrize(
"constraint,result",
[
("^1.0", False),
("^1.0.dev0", True),
("^1.0.0", False),
("^1.0.0.dev0", True),
("^1.0.0.alpha0", True),
("^1.0.0.alpha0+local", True),
("^1.0.0.rc0+local", True),
("^1.0.0-1", False),
],
)
def test_allows_prerelease(constraint: str, result: bool) -> None:
assert Dependency("A", constraint).allows_prereleases() == result


def test_to_pep_508() -> None:
dependency = Dependency("Django", "^1.23")

Expand Down

0 comments on commit 1e6e668

Please sign in to comment.