-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Description
I may be in a need of the following - two TypeDict
s with the same keys, one of them created with total=False
:
from mypy_extensions import TypedDict
Details = TypedDict('Details', {'name': str, 'age': int, 'address': str})
DetailsSubset = TypedDict('DetailsSubset', {'name': str, 'age': int, 'address': str}, total=False)
Is there a way to reuse the keys instead of having to repeat the {'name': str, 'age': int, address: str}
fragment twice?
I can't do
from mypy_extensions import TypedDict
keys = {'name': str, 'age': int, 'address': str}
Details = TypedDict('Details', keys)
DetailsSubset = TypedDict('DetailsSubset', keys, total=False)
Because
% mypy code.py
code.py:4: error: TypedDict() expects a dictionary literal as the second argument
code.py:5: error: TypedDict() expects a dictionary literal as the second argument
(which is quite reasonable, tried that on the off chance it'd work)
multimac, shabbyrobe, cwhy, cancan101, mrwonko and 23 more