From d99f934ab9f8367886b388c724ee34d67475a9f8 Mon Sep 17 00:00:00 2001 From: "Kai (Kazuya Ito)" Date: Thu, 29 Jan 2026 23:38:18 +0900 Subject: [PATCH 1/2] Clarify error message for unpacking TypedDict --- mypy/semanal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/semanal.py b/mypy/semanal.py index 17176e9210512..f38a71cb16e30 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -1104,7 +1104,7 @@ def remove_unpack_kwargs(self, defn: FuncDef, typ: CallableType) -> CallableType return typ p_last_type = get_proper_type(last_type.type) if not isinstance(p_last_type, TypedDictType): - self.fail("Unpack item in ** argument must be a TypedDict", last_type) + self.fail("Unpack item in ** parameter must be a TypedDict", last_type) new_arg_types = typ.arg_types[:-1] + [AnyType(TypeOfAny.from_error)] return typ.copy_modified(arg_types=new_arg_types) overlap = set(typ.arg_names) & set(p_last_type.items) From 3c6ad05b3acaf8a42ddfbec99f53ab728a8d213c Mon Sep 17 00:00:00 2001 From: "Kai (Kazuya Ito)" Date: Thu, 29 Jan 2026 23:41:02 +0900 Subject: [PATCH 2/2] Fix error message in bad_kwargs function definition --- test-data/unit/semanal-errors.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-data/unit/semanal-errors.test b/test-data/unit/semanal-errors.test index 2526d633fbb8b..b69d35ce030e7 100644 --- a/test-data/unit/semanal-errors.test +++ b/test-data/unit/semanal-errors.test @@ -1471,7 +1471,7 @@ class Variadic(Generic[Unpack[TVariadic], Unpack[TVariadic2]]): # E: Can only u def bad_args(*args: TVariadic): # E: TypeVarTuple "TVariadic" is only valid with an unpack pass -def bad_kwargs(**kwargs: Unpack[TVariadic]): # E: Unpack item in ** argument must be a TypedDict +def bad_kwargs(**kwargs: Unpack[TVariadic]): # E: Unpack item in ** parameter must be a TypedDict pass [builtins fixtures/dict.pyi]