From 93b773fd5799a4c217ef35281e602cb07489a468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Fri, 1 Apr 2022 17:13:46 +0200 Subject: [PATCH] Fix an issue where dependencies with an epoch are parsed as empty * remove duplicated and buggy method of first_pre_release() and use correct method first_prerelase() --- src/poetry/core/semver/version.py | 3 --- src/poetry/core/semver/version_range.py | 2 +- tests/semver/test_helpers.py | 27 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/poetry/core/semver/version.py b/src/poetry/core/semver/version.py index a3c772348..e0144b97d 100644 --- a/src/poetry/core/semver/version.py +++ b/src/poetry/core/semver/version.py @@ -48,9 +48,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 diff --git a/src/poetry/core/semver/version_range.py b/src/poetry/core/semver/version_range.py index ae4a5958a..7e6e7d8bd 100644 --- a/src/poetry/core/semver/version_range.py +++ b/src/poetry/core/semver/version_range.py @@ -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 diff --git a/tests/semver/test_helpers.py b/tests/semver/test_helpers.py index 6e8f11286..31a224ad5 100644 --- a/tests/semver/test_helpers.py +++ b/tests/semver/test_helpers.py @@ -274,6 +274,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.*"],