Skip to content

Commit 04efeb2

Browse files
authored
Fix crash with tuple unpack inside TypeVar default (#20456)
Fixes #20451
1 parent 9bdcfdf commit 04efeb2

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

mypy/mixedtraverser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def visit_type_alias_expr(self, o: TypeAliasExpr, /) -> None:
5858
def visit_type_var_expr(self, o: TypeVarExpr, /) -> None:
5959
super().visit_type_var_expr(o)
6060
o.upper_bound.accept(self)
61+
o.default.accept(self)
6162
for value in o.values:
6263
value.accept(self)
6364

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)