Skip to content

Commit

Permalink
Fix an issue where dependencies with an epoch are parsed as empty
Browse files Browse the repository at this point in the history
* remove duplicated and buggy method of first_pre_release() and use correct method first_prerelase()
  • Loading branch information
radoering committed Apr 1, 2022
1 parent 65ddc9e commit d9df789
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
3 changes: 0 additions & 3 deletions src/poetry/core/semver/version.py
Expand Up @@ -49,9 +49,6 @@ def next_breaking(self) -> "Version":

return self.stable.next_major()

def first_pre_release(self) -> "Version":
return self.__class__(release=self.release, pre=ReleaseTag("alpha"))

@property
def min(self) -> "Version":
return self
Expand Down
2 changes: 1 addition & 1 deletion src/poetry/core/semver/version_range.py
Expand Up @@ -30,7 +30,7 @@ def __init__(
and not full_max.is_postrelease()
and (min is None or min.is_stable() or min.release != full_max.release)
):
full_max = full_max.first_pre_release()
full_max = full_max.first_prerelease()

self._min = min
self._max = max
Expand Down
27 changes: 27 additions & 0 deletions tests/semver/test_helpers.py
Expand Up @@ -275,6 +275,33 @@ def test_parse_constraint_multi(input: str):
)


@pytest.mark.parametrize(
"input, output",
[
(
">1!2,<=2!3",
VersionRange(
Version.from_parts(2, 0, 0, epoch=1),
Version.from_parts(3, 0, 0, epoch=2),
include_min=False,
include_max=True,
),
),
(
">= 1!2,<2!3",
VersionRange(
Version.from_parts(2, 0, 0, epoch=1),
Version.from_parts(3, 0, 0, epoch=2),
include_min=True,
include_max=False,
),
),
],
)
def test_parse_constraint_multi_with_epochs(input: str, output: VersionRange):
assert parse_constraint(input) == output


@pytest.mark.parametrize(
"input",
[">=2.7,!=3.0.*,!=3.1.*", ">=2.7, !=3.0.*, !=3.1.*", ">= 2.7, != 3.0.*, != 3.1.*"],
Expand Down

0 comments on commit d9df789

Please sign in to comment.