#21024 made stubtest expand **kwargs: Unpack[TypedDict] for plain functions, but not for overloaded ones.
In django-stubs we are trying to factor the kwargs shared by every Field.__init__ overload into a TypedDict, to avoid spelling the same ones over and over.
error: pkg.overloaded is inconsistent, stub does not have parameter "a"
Stub: in file pkg/__init__.pyi:9
Overload(def (x: Literal[True], **kwargs: **TypedDict(pkg.KW, {'a'?: int, 'b'?: int})), def (x: bool, **kwargs: **TypedDict(pkg.KW, {'a'?: int, 'b'?: int})))
Inferred signature: def (x: bool, **kwargs)
Runtime: in file pkg/__init__.py:2
def (x, *, a=0, b=0)
error: pkg.overloaded is inconsistent, stub does not have parameter "b"
...
error: pkg.overloaded is inconsistent, runtime does not have **kwargs parameter "kwargs"
...
Found 3 errors (checked 1 module)
Your Environment
Mypy version used: 2.4.0
Mypy command-line flags: none
Mypy configuration options from mypy.ini (and other config files): none
I can reproduce this on master (eaeb098). The TypedDict expansion from #21024 only happens in Signature.from_funcitem. from_overloadedfuncdef builds its signature from the raw func.arguments, so overloads still see a plain **kwargs.
Moving the expansion into a small helper and calling it on each overload item's arguments fixes the example here. All stubtest tests pass, and I added overload cases to test_kwargs_unpack_typeddict. I'll open a PR shortly.
Activity
NavpreetSSidhu commented on Oct 20, 2026
I can reproduce this on master (eaeb098). The TypedDict expansion from #21024 only happens in Signature.from_funcitem. from_overloadedfuncdef builds its signature from the raw func.arguments, so overloads still see a plain **kwargs.
Moving the expansion into a small helper and calling it on each overload item's arguments fixes the example here. All stubtest tests pass, and I added overload cases to test_kwargs_unpack_typeddict. I'll open a PR shortly.
stubtest: expand Unpack[TypedDict] kwargs in overloads (#22239)