Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions mypy/nativeparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
read_bool,
read_int,
read_str,
read_str_opt,
read_tag,
)
from mypy.nodes import (
Expand Down Expand Up @@ -142,9 +143,11 @@
CallableType,
EllipsisType,
Instance,
ProperType,
RawExpressionType,
TupleType,
Type,
TypedDictType,
TypeList,
TypeOfAny,
UnboundType,
Expand Down Expand Up @@ -985,6 +988,26 @@ def read_type(state: State, data: ReadBuffer) -> Type:
read_loc(data, tuple_type)
expect_end_tag(data)
return tuple_type
elif tag == types.TYPED_DICT_TYPE:
expect_tag(data, LIST_GEN)
n = read_int_bare(data)
keys = [read_str_opt(data) for i in range(n)]
expect_tag(data, LIST_GEN)
n = read_int_bare(data)
values = [read_type(state, data) for i in range(n)]
td_items = {}
extra_items_from = []
for key, val in zip(keys, values):
if key is None:
assert isinstance(val, ProperType)
extra_items_from.append(val)
else:
td_items[key] = val
typeddict_type = TypedDictType(td_items, set(), set(), _dummy_fallback)
typeddict_type.extra_items_from = extra_items_from
read_loc(data, typeddict_type)
expect_end_tag(data)
return typeddict_type
elif tag == types.ELLIPSIS_TYPE:
# EllipsisType has no attributes
ellipsis_type = EllipsisType()
Expand Down