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.*"],