Skip to content

Fix & Update TypedDict keyword argument unpacking - #22449

Open
terencehonles wants to merge 1 commit into
python:masterfrom
terencehonles:fix-typeddict-unpacking
Open

terencehonles wants to merge 1 commit into
python:masterfrom
terencehonles:fix-typeddict-unpacking

Conversation

@terencehonles

@terencehonles terencehonles commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

This change fixes mypy crashing while unpacking TypedDicts with overlapping keyword names, and now properly warns if the required_keys of unpacked TypedDicts overlap.


mypy playground

Traceback:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "mypy/checkexpr.py", line 6194, in accept
  File "mypy/checkexpr.py", line 502, in visit_call_expr
  File "mypy/checkexpr.py", line 633, in visit_call_expr_inner
  File "mypy/checkexpr.py", line 1501, in check_call_expr_with_callee_type
  File "mypy/checkexpr.py", line 1594, in check_call
  File "mypy/checkexpr.py", line 1888, in check_callable_call
  File "mypy/checkexpr.py", line 2770, in check_argument_types
  File "mypy/argmap.py", line 251, in expand_actual_type
KeyError: 'pop from an empty set'

main.py:10: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 2.4.1
main.py:10: note: use --pdb to drop into pdb

H/T: @UnknownPlatypus

This change fixes mypy crashing while unpacking `TypedDict`s with
overlapping keyword names, and now properly warns if the `required_keys`
of unpacked `TypedDict`s overlap.
@terencehonles
terencehonles force-pushed the fix-typeddict-unpacking branch from baad8e2 to 5766df4 Compare November 12, 2026 12:52
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

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.

1 participant