Skip to content

Commit

Permalink
preserver marker order at union
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby authored and neersighted committed May 30, 2022
1 parent a6fe563 commit e016bd3
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/poetry/core/version/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,22 @@ def union_simplify(self, other: BaseMarker) -> BaseMarker | None:
return other

elif isinstance(other, MultiMarker):
markers = set(self._markers)
other_markers = set(other.markers)
common_markers = markers & other_markers
unique_markers = markers - common_markers
common_markers = [
marker for marker in self.markers if marker in other.markers
]

unique_markers = [
marker for marker in self.markers if marker not in common_markers
]
if not unique_markers:
return self
other_unique_markers = other_markers - common_markers

other_unique_markers = [
marker for marker in other.markers if marker not in common_markers
]
if not other_unique_markers:
return other

if common_markers:
unique_union = self.of(*unique_markers).union(
self.of(*other_unique_markers)
Expand Down

0 comments on commit e016bd3

Please sign in to comment.