diff --git a/poetry/core/semver/version.py b/poetry/core/semver/version.py index 3246d0f34..72ee8c699 100644 --- a/poetry/core/semver/version.py +++ b/poetry/core/semver/version.py @@ -15,7 +15,6 @@ if TYPE_CHECKING: from poetry.core.semver.helpers import VersionTypes - from poetry.core.semver.version_range import VersionRange from poetry.core.version.pep440 import LocalSegmentType @@ -150,7 +149,7 @@ def __str__(self) -> str: def __repr__(self) -> str: return "".format(str(self)) - def __eq__(self, other: Union["Version", "VersionRange"]) -> bool: + def __eq__(self, other: Union["Version", "VersionRangeConstraint"]) -> bool: from poetry.core.semver.version_range import VersionRange if isinstance(other, VersionRange): diff --git a/poetry/core/semver/version_range.py b/poetry/core/semver/version_range.py index e7860d95f..c4b3dff21 100644 --- a/poetry/core/semver/version_range.py +++ b/poetry/core/semver/version_range.py @@ -104,7 +104,7 @@ def allows_all(self, other: "VersionTypes") -> bool: if isinstance(other, VersionUnion): return all([self.allows_all(constraint) for constraint in other.ranges]) - if isinstance(other, VersionRange): + if isinstance(other, VersionRangeConstraint): return not other.allows_lower(self) and not other.allows_higher(self) raise ValueError("Unknown VersionConstraint type {}.".format(other)) @@ -121,7 +121,7 @@ def allows_any(self, other: "VersionTypes") -> bool: if isinstance(other, VersionUnion): return any([self.allows_any(constraint) for constraint in other.ranges]) - if isinstance(other, VersionRange): + if isinstance(other, VersionRangeConstraint): return not other.is_strictly_lower(self) and not other.is_strictly_higher( self ) @@ -144,7 +144,7 @@ def intersect(self, other: "VersionTypes") -> "VersionTypes": return EmptyConstraint() - if not isinstance(other, VersionRange): + if not isinstance(other, VersionRangeConstraint): raise ValueError("Unknown VersionConstraint type {}.".format(other)) if self.allows_lower(other): @@ -202,7 +202,7 @@ def union(self, other: "VersionTypes") -> "VersionTypes": return VersionUnion.of(self, other) - if isinstance(other, VersionRange): + if isinstance(other, VersionRangeConstraint): # If the two ranges don't overlap, we won't be able to create a single # VersionRange for both of them. edges_touch = ( @@ -261,7 +261,7 @@ def difference(self, other: "VersionTypes") -> "VersionTypes": VersionRange(self.min, other, self.include_min, False), VersionRange(other, self.max, False, self.include_max), ) - elif isinstance(other, VersionRange): + elif isinstance(other, VersionRangeConstraint): if not self.allows_any(other): return self @@ -326,7 +326,7 @@ def difference(self, other: "VersionTypes") -> "VersionTypes": raise ValueError("Unknown VersionConstraint type {}.".format(other)) def __eq__(self, other: Any) -> int: - if not isinstance(other, VersionRange): + if not isinstance(other, VersionRangeConstraint): return False return ( @@ -336,19 +336,19 @@ def __eq__(self, other: Any) -> int: and self._include_max == other.include_max ) - def __lt__(self, other: "VersionRange") -> int: + def __lt__(self, other: "VersionRangeConstraint") -> int: return self._cmp(other) < 0 - def __le__(self, other: "VersionRange") -> int: + def __le__(self, other: "VersionRangeConstraint") -> int: return self._cmp(other) <= 0 - def __gt__(self, other: "VersionRange") -> int: + def __gt__(self, other: "VersionRangeConstraint") -> int: return self._cmp(other) > 0 - def __ge__(self, other: "VersionRange") -> int: + def __ge__(self, other: "VersionRangeConstraint") -> int: return self._cmp(other) >= 0 - def _cmp(self, other: "VersionRange") -> int: + def _cmp(self, other: "VersionRangeConstraint") -> int: if self.min is None: if other.min is None: return self._compare_max(other) diff --git a/poetry/core/version/markers.py b/poetry/core/version/markers.py index 93f5f1e34..ffea9beb1 100644 --- a/poetry/core/version/markers.py +++ b/poetry/core/version/markers.py @@ -325,9 +325,11 @@ def invert(self) -> MarkerTypes: # This one is more tricky to handle # since it's technically a multi marker # so the inverse will be a union of inverse - from poetry.core.semver.version_range import VersionRange + from poetry.core.semver.version_range_constraint import ( + VersionRangeConstraint, + ) - if not isinstance(self._constraint, VersionRange): + if not isinstance(self._constraint, VersionRangeConstraint): # The constraint must be a version range, otherwise # it's an internal error raise RuntimeError(