Skip to content

Commit 185b2c9

Browse files
authored
Use "parameter" instead of "argument" in unpacking error (#20683)
Fixes #20679
1 parent 5917b80 commit 185b2c9

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

mypy/semanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ def remove_unpack_kwargs(self, defn: FuncDef, typ: CallableType) -> CallableType
11041104
return typ
11051105
p_last_type = get_proper_type(last_type.type)
11061106
if not isinstance(p_last_type, TypedDictType):
1107-
self.fail("Unpack item in ** argument must be a TypedDict", last_type)
1107+
self.fail("Unpack item in ** parameter must be a TypedDict", last_type)
11081108
new_arg_types = typ.arg_types[:-1] + [AnyType(TypeOfAny.from_error)]
11091109
return typ.copy_modified(arg_types=new_arg_types)
11101110
overlap = set(typ.arg_names) & set(p_last_type.items)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,15 +2191,15 @@ g(1, 2, 3) # E: Missing named argument "a" for "g" \
21912191

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

21982198
def bad2(
21992199
one: int,
22002200
*args: Unpack[Keywords], # E: "Keywords" cannot be unpacked (must be tuple or TypeVarTuple)
22012201
other: str = "no",
2202-
**kwargs: Unpack[Ints], # E: Unpack item in ** argument must be a TypedDict
2202+
**kwargs: Unpack[Ints], # E: Unpack item in ** parameter must be a TypedDict
22032203
) -> None: ...
22042204
reveal_type(bad2) # N: Revealed type is "def (one: builtins.int, *args: Any, other: builtins.str =, **kwargs: Any)"
22052205
[builtins fixtures/dict.pyi]

test-data/unit/check-varargs.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ def baz(**kwargs: Unpack[Person]) -> None: # OK
792792
[case testUnpackWithoutTypedDict]
793793
from typing_extensions import Unpack
794794

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

test-data/unit/semanal-errors.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,7 @@ class Variadic(Generic[Unpack[TVariadic], Unpack[TVariadic2]]): # E: Can only u
14711471
def bad_args(*args: TVariadic): # E: TypeVarTuple "TVariadic" is only valid with an unpack
14721472
pass
14731473

1474-
def bad_kwargs(**kwargs: Unpack[TVariadic]): # E: Unpack item in ** argument must be a TypedDict
1474+
def bad_kwargs(**kwargs: Unpack[TVariadic]): # E: Unpack item in ** parameter must be a TypedDict
14751475
pass
14761476

14771477
[builtins fixtures/dict.pyi]

0 commit comments

Comments
 (0)