Skip to content

Commit 8ed26e5

Browse files
sterliakovilevkivskyi
authored andcommitted
Fix crash on multiple unpacks in a bare type application (#18857)
Fixes #18856. This should be done by `TypeAnalyzer.anal_array` but is not - semanal only invokes its own wrapper around `anal_type` --------- Co-authored-by: Ivan Levkivskyi <[email protected]>
1 parent 0cd434f commit 8ed26e5

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

mypy/semanal.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6041,6 +6041,8 @@ def analyze_type_application_args(self, expr: IndexExpr) -> list[Type] | None:
60416041
return None
60426042
types.append(analyzed)
60436043

6044+
if allow_unpack:
6045+
types = self.type_analyzer().check_unpacks_in_list(types)
60446046
if has_param_spec and num_args == 1 and types:
60456047
first_arg = get_proper_type(types[0])
60466048
single_any = len(types) == 1 and isinstance(first_arg, AnyType)

mypy/typeanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2006,7 +2006,7 @@ def check_unpacks_in_list(self, items: list[Type]) -> list[Type]:
20062006

20072007
if num_unpacks > 1:
20082008
assert final_unpack is not None
2009-
self.fail("More than one Unpack in a type is not allowed", final_unpack)
2009+
self.fail("More than one Unpack in a type is not allowed", final_unpack.type)
20102010
return new_items
20112011

20122012
def tuple_type(self, items: list[Type], line: int, column: int) -> TupleType:

0 commit comments

Comments
 (0)