Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 440 compliance: do not implicitly allow pre-releases #543

Merged
merged 2 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ref: ["master", "1.3"]
ref: ["master"]
fail-fast: false
defaults:
run:
Expand Down
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
24 changes: 13 additions & 11 deletions tests/packages/test_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@


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


def test_to_pep_508() -> None:
Expand Down