Closed
Description
This appears to be due to TypedDict relying on a fallback.
from typing import List, Optional
from mypy_extensions import TypedDict
TaggedPoint = TypedDict('TaggedPoint', {'type': str, 'x': int, 'y': int})
Point3D = TypedDict('Point3D', {'x': int, 'y': int, 'z': int})
BadPointSet = TypedDict('BadPointSet', {
'total_length': int,
'points': List[TaggedPoint]
})
OKPointSet = TypedDict('OKPointSet', {
'points': List[TaggedPoint]
})
def foo(point_3d: Point3D,
tagged_point: TaggedPoint,
bad_points: BadPointSet,
ok_points: OKPointSet) -> None:
reveal_type(point_3d.get('x')) # error: Revealed type is 'builtins.int*
reveal_type(tagged_point.get('x')) # error: Revealed type is 'builtins.object*
reveal_type(bad_points.get('points')) # error: Revealed type is 'builtins.object*'
reveal_type(ok_points.get('points')) # Revealed type is 'builtins.list*[TypedDict(x=builtins.int, y=builtins.int, _fallback=test_typed_dict_get.TaggedPoint)]'