@@ -734,16 +734,16 @@ def union_simplify(self, other: BaseMarker) -> BaseMarker | None:
734
734
if not shared_markers :
735
735
return None
736
736
737
- unique_markers = our_markers - their_markers
738
- other_unique_markers = their_markers - our_markers
737
+ # Do not use sets to create MarkerUnions for deterministic order!
738
+ unique_markers = (m for m in self .markers if m not in their_markers )
739
+ other_unique_markers = (m for m in other .markers if m not in our_markers )
739
740
unique_union = MultiMarker (* unique_markers ).union (
740
741
MultiMarker (* other_unique_markers )
741
742
)
742
743
if isinstance (unique_union , (SingleMarkerLike , AnyMarker )):
743
- # Use list instead of set for deterministic order.
744
- common_markers = [
744
+ common_markers = (
745
745
marker for marker in self .markers if marker in shared_markers
746
- ]
746
+ )
747
747
return unique_union .intersect (MultiMarker (* common_markers ))
748
748
749
749
return None
@@ -908,16 +908,16 @@ def intersect_simplify(self, other: BaseMarker) -> BaseMarker | None:
908
908
if not shared_markers :
909
909
return None
910
910
911
- unique_markers = our_markers - their_markers
912
- other_unique_markers = their_markers - our_markers
911
+ # Do not use sets to create MarkerUnions for deterministic order!
912
+ unique_markers = (m for m in self .markers if m not in their_markers )
913
+ other_unique_markers = (m for m in other .markers if m not in our_markers )
913
914
unique_intersection = MarkerUnion (* unique_markers ).intersect (
914
915
MarkerUnion (* other_unique_markers )
915
916
)
916
917
if isinstance (unique_intersection , (SingleMarkerLike , EmptyMarker )):
917
- # Use list instead of set for deterministic order.
918
- common_markers = [
918
+ common_markers = (
919
919
marker for marker in self .markers if marker in shared_markers
920
- ]
920
+ )
921
921
return unique_intersection .union (MarkerUnion (* common_markers ))
922
922
923
923
return None
0 commit comments