We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bd6ce23 commit 315b466Copy full SHA for 315b466
mypyc/ir/rtypes.py
@@ -820,17 +820,11 @@ def make_simplified_union(items: list[RType]) -> RType:
820
items = flatten_nested_unions(items)
821
assert items
822
823
- # Remove duplicate items using set + list to preserve item order
824
- seen = set()
825
- new_items = []
826
- for item in items:
827
- if item not in seen:
828
- new_items.append(item)
829
- seen.add(item)
830
- if len(new_items) > 1:
831
- return RUnion(new_items)
+ unique_items = dict.fromkeys(items)
+ if len(unique_items) > 1:
+ return RUnion(list(unique_items))
832
else:
833
- return new_items[0]
+ return next(iter(unique_items))
834
835
def accept(self, visitor: RTypeVisitor[T]) -> T:
836
return visitor.visit_runion(self)
0 commit comments