Open BerendKemper opened 4 days ago
TypedDict
is how the Python type system supports dictionaries with individually-typed items. You can read more about this facility in the official Python typing spec. A regular dict
subclass cannot specify the types of individual items, but you can use dict[str, Any]
to represent a dictionary whose keys are all str
and whose values are any type.
TypedDicts are awsome in combination with PyLance because thanks to PyLance i get to see type hinting from objects implementing a TypeDict. Such as in the screenshot the variable
obj2
has Type Hinting.Is there a feature out there that can implement a TypeDict's type hinting to a dict subclass (since, unlike TypeDict, a dict subclass can implement custom methods)?