Skip to content

Commit ef41ff1

Browse files
committed
Couple tuple-related fixes
1 parent 840bd1e commit ef41ff1

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

mypy/nativeparse.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
EllipsisType,
144144
Instance,
145145
RawExpressionType,
146+
TupleType,
146147
Type,
147148
TypeList,
148149
TypeOfAny,
@@ -904,6 +905,7 @@ def read_type(state: State, data: ReadBuffer) -> Type:
904905
expect_tag(data, LIST_GEN)
905906
n = read_int_bare(data)
906907
args = tuple(read_type(state, data) for i in range(n))
908+
empty_tuple_index = read_bool(data)
907909
# Read optional original_str_expr
908910
t = read_tag(data)
909911
if t == LITERAL_NONE:
@@ -923,6 +925,7 @@ def read_type(state: State, data: ReadBuffer) -> Type:
923925
unbound = UnboundType(
924926
name,
925927
args,
928+
empty_tuple_index=empty_tuple_index,
926929
original_str_expr=original_str_expr,
927930
original_str_fallback=original_str_fallback,
928931
)
@@ -967,6 +970,16 @@ def read_type(state: State, data: ReadBuffer) -> Type:
967970
read_loc(data, type_list)
968971
expect_end_tag(data)
969972
return type_list
973+
elif tag == types.TUPLE_TYPE:
974+
# Read items list
975+
expect_tag(data, LIST_GEN)
976+
n = read_int_bare(data)
977+
items = [read_type(state, data) for i in range(n)]
978+
implicit = read_bool(data)
979+
tuple_type = TupleType(items, _dummy_fallback, implicit=implicit)
980+
read_loc(data, tuple_type)
981+
expect_end_tag(data)
982+
return tuple_type
970983
elif tag == types.ELLIPSIS_TYPE:
971984
# EllipsisType has no attributes
972985
ellipsis_type = EllipsisType()

0 commit comments

Comments
 (0)