Skip to content

Commit 2c1b1a1

Browse files
committed
TupleType fallbacks as Instances, not Unions
1 parent 121d8e1 commit 2c1b1a1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mypy/join.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,12 +607,17 @@ def visit_tuple_type(self, t: TupleType) -> ProperType:
607607
# * Joining with any Sequence also returns a Sequence:
608608
# Tuple[int, bool] + List[bool] becomes Sequence[int]
609609
if isinstance(self.s, TupleType):
610+
610611
if self.instance_joiner is None:
611612
self.instance_joiner = InstanceJoiner()
613+
prefer_union = self.instance_joiner.prefer_union_over_supertype
614+
self.instance_joiner.prefer_union_over_supertype = False
612615
fallback = self.instance_joiner.join_instances(
613616
mypy.typeops.tuple_fallback(self.s), mypy.typeops.tuple_fallback(t)
614617
)
615-
assert isinstance(fallback, Instance), f"s = {self.s}, t = {t}, f = {fallback}"
618+
assert isinstance(fallback, Instance)
619+
self.instance_joiner.prefer_union_over_supertype = prefer_union
620+
616621
items = self.join_tuples(self.s, t)
617622
if items is not None:
618623
return TupleType(items, fallback)

0 commit comments

Comments
 (0)