Skip to content

stubtest: basic support for unpack kwargs - #21024

Merged
hauntsaninja merged 2 commits into
python:masterfrom
hauntsaninja:stubtestunpack
Apr 22, 2026
Merged

hauntsaninja merged 2 commits into
python:masterfrom
hauntsaninja:stubtestunpack

Conversation

@hauntsaninja

Copy link
Copy Markdown
Collaborator

Fixes #21023

Comment thread mypy/test/teststubtest.py
Comment thread mypy/stubtest.py
Comment thread mypy/test/teststubtest.py Outdated
@hauntsaninja
hauntsaninja merged commit f4db3cd into python:master Apr 22, 2026
17 checks passed
@hauntsaninja
hauntsaninja deleted the stubtestunpack branch April 22, 2026 04:46
@hauntsaninja

Copy link
Copy Markdown
Collaborator Author

Thank you for the review!

hauntsaninja pushed a commit that referenced this pull request Oct 21, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants