From febc9f40f8a1fa19f2a20de3275c1e502c06f2a3 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Fri, 5 May 2023 13:00:16 +0100 Subject: [PATCH] fix allows_any() with local versions --- src/poetry/core/constraints/version/version.py | 5 ++++- tests/constraints/version/test_version.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/poetry/core/constraints/version/version.py b/src/poetry/core/constraints/version/version.py index faba17392..1d032acb4 100644 --- a/src/poetry/core/constraints/version/version.py +++ b/src/poetry/core/constraints/version/version.py @@ -93,10 +93,13 @@ def allows_all(self, other: VersionConstraint) -> bool: ) def allows_any(self, other: VersionConstraint) -> bool: + if other.allows(self): + return True + if isinstance(other, Version): return self.allows(other) - return other.allows(self) + return False def intersect(self, other: VersionConstraint) -> Version | EmptyConstraint: if other.allows(self): diff --git a/tests/constraints/version/test_version.py b/tests/constraints/version/test_version.py index dba08787b..124f8021f 100644 --- a/tests/constraints/version/test_version.py +++ b/tests/constraints/version/test_version.py @@ -377,7 +377,7 @@ def test_allows_all() -> None: ( Version.parse("1.2.3+cpu"), Version.parse("1.2.3"), - False, + True, ), ( Version.parse("1.2.3"),