Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/check-typevar-tuple.test
Original file line number Diff line number Diff line change
Expand Up @@ -2191,15 +2191,15 @@ g(1, 2, 3) # E: Missing named argument "a" for "g" \

def bad(
*args: Unpack[Keywords], # E: "Keywords" cannot be unpacked (must be tuple or TypeVarTuple)
**kwargs: Unpack[Ints], # E: Unpack item in ** argument must be a TypedDict
**kwargs: Unpack[Ints], # E: Unpack item in ** parameter must be a TypedDict
) -> None: ...
reveal_type(bad) # N: Revealed type is "def (*args: Any, **kwargs: Any)"

def bad2(
one: int,
*args: Unpack[Keywords], # E: "Keywords" cannot be unpacked (must be tuple or TypeVarTuple)
other: str = "no",
**kwargs: Unpack[Ints], # E: Unpack item in ** argument must be a TypedDict
**kwargs: Unpack[Ints], # E: Unpack item in ** parameter must be a TypedDict
) -> None: ...
reveal_type(bad2) # N: Revealed type is "def (one: builtins.int, *args: Any, other: builtins.str =, **kwargs: Any)"
[builtins fixtures/dict.pyi]
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-varargs.test
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ def baz(**kwargs: Unpack[Person]) -> None: # OK
[case testUnpackWithoutTypedDict]
from typing_extensions import Unpack

def foo(**kwargs: Unpack[dict]) -> None: # E: Unpack item in ** argument must be a TypedDict
def foo(**kwargs: Unpack[dict]) -> None: # E: Unpack item in ** parameter must be a TypedDict
...
[builtins fixtures/dict.pyi]

Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/semanal-errors.test
Original file line number Diff line number Diff line change
Expand Up @@ -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]