Skip to content

Commit 905e7ab

Browse files
committed
Fix crash with tuple unpack inside TypeVar default
1 parent 72cff30 commit 905e7ab

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

mypy/typeops.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ def tuple_fallback(typ: TupleType) -> Instance:
113113
and unpacked_type.type.fullname == "builtins.tuple"
114114
):
115115
items.append(unpacked_type.args[0])
116+
elif isinstance(unpacked_type, TupleType):
117+
items.extend(unpacked_type.items)
116118
else:
117119
raise NotImplementedError
118120
else:

test-data/unit/check-typevar-defaults.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ T4 = TypeVar("T4", int, str, default=int)
4242
T5 = TypeVar("T5", default=S0)
4343
T6 = TypeVar("T6", bound=float, default=S1)
4444
T7 = TypeVar("T7", bound=List[Any], default=List[S0])
45+
T8 = TypeVar("T8", default=Tuple[int, Unpack[Tuple[int, str]]])
4546

4647
P1 = ParamSpec("P1", default=[])
4748
P2 = ParamSpec("P2", default=...)

0 commit comments

Comments
 (0)