-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
Feature
Currently TypedDict type checking rejects spread keyword arguments as a type violation, even when a TypedDict is provided as the spread source. Typing information is available and the spread operation works at runtime, so the error received is ... misleading at best, but also I think the spread should be possible, leveraging the typing from the source TypedDict.
Pitch
I would like to be able to do this (a simplified version of what I really want to do, which involves much larger typed dicts):
class Spam(TypedDict):
one: str
x = Spam(one='one')
Spam(**x)
This currently results in this error from mypy:
x.py:5: error: Expected keyword arguments, {...}, or dict(...) in TypedDict constructor [misc]
(note that the code executes successfully because the spread does work)
beegibson, iyawnis, sobolevn, graingert, jcordial and 7 more