Skip to content

Commit ea8c8f9

Browse files
authored
Update error message for parameter overlap in TypedDict (#20956)
Fixes #20933
1 parent e900923 commit ea8c8f9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

mypy/semanal.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,9 @@ def remove_unpack_kwargs(self, defn: FuncDef, typ: CallableType) -> CallableType
11251125
overlap.discard(typ.arg_names[-1])
11261126
if overlap:
11271127
overlapped = ", ".join([f'"{name}"' for name in sorted(filter(None, overlap))])
1128-
self.fail(f"Overlap between argument names and ** TypedDict items: {overlapped}", defn)
1128+
self.fail(
1129+
f"Overlap between parameter names and ** TypedDict items: {overlapped}", defn
1130+
)
11291131
new_arg_types = typ.arg_types[:-1] + [AnyType(TypeOfAny.from_error)]
11301132
return typ.copy_modified(arg_types=new_arg_types)
11311133
# OK, everything looks right now, mark the callable type as using unpack.

test-data/unit/check-varargs.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ from typing_extensions import Unpack
803803
class Person(TypedDict):
804804
name: str
805805
age: int
806-
def foo(name: str, **kwargs: Unpack[Person]) -> None: # E: Overlap between argument names and ** TypedDict items: "name"
806+
def foo(name: str, **kwargs: Unpack[Person]) -> None: # E: Overlap between parameter names and ** TypedDict items: "name"
807807
...
808808
[builtins fixtures/dict.pyi]
809809
[typing fixtures/typing-typeddict.pyi]

0 commit comments

Comments
 (0)