-
-
Notifications
You must be signed in to change notification settings - Fork 133
Closed
Labels
Description
- cattrs version: 22.1.0
- Python version: 3.9.13
- Operating System: macOS 12.5
Description
I know cattrs does not currently support TypedDict. Is this something that would make sense as a new feature?
I want to convert an input dict into an output dict, ideally with a structure defined as a TypedDict. Each value in the input dict should be converted to the correspondent type in the TypedDict definition. The problem was described in https://stackoverflow.com/q/65196658/2654518.
What I Did
from typing import TypedDict
import cattrs
class Test(TypedDict):
value: int
cattrs.structure({'value': '42', 'foo': 'bar'}, Test)With TypedDict support, the output would be {'value': 42}, instead of {'value': '42', 'foo': 'bar'}.
Reactions are currently unavailable