1from typing_extensions import TypedDict
2class Point2D(TypedDict):
3 x: int
4 y: int
5 label: str
6
7a: Point2D = {'x': 1, 'y': 2, 'label': 'good'} # OK
8b: Point2D = {'z': 3, 'label': 'bad'} # Fails type check
9
10assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')