Skip to content

stubtest: expand Unpack[TypedDict] kwargs in overloads - #22239

Open
NavpreetSSidhu wants to merge 1 commit into
python:masterfrom
NavpreetSSidhu:stubtest-overload-unpack-kwargs
Open

NavpreetSSidhu wants to merge 1 commit into
python:masterfrom
NavpreetSSidhu:stubtest-overload-unpack-kwargs

Conversation

@NavpreetSSidhu

Copy link
Copy Markdown

Fixes #22238

#21024 made stubtest expand **kwargs: Unpack[TypedDict] into keyword arguments, but only in Signature.from_funcitem. Overloads go through from_overloadedfuncdef, which reads each item's raw arguments, so they still got a plain **kwargs and stubtest reported every key as missing.

This moves the expansion into expand_unpacked_kwargs() and applies it to plain functions and to each overload item. The merged overload signature then picks up the keys like any other keyword arguments, so a key only present in some overloads is treated as optional.

Added two overload cases to test_kwargs_unpack_typeddict: one that matches the runtime and one where the runtime has a different keyword. The new test fails on master and passes with this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stubtest doesn't expand **kwargs: Unpack[...] in overloads

1 participant