Skip to content

Commit deaaccf

Browse files
author
th3-j4ck4l
committed
Resolves #8627
1 parent d54fc8e commit deaaccf

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

mypy/fastparse.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -1504,17 +1504,22 @@ def visit_Bytes(self, n: Bytes) -> Type:
15041504

15051505
# Subscript(expr value, slice slice, expr_context ctx)
15061506
def visit_Subscript(self, n: ast3.Subscript) -> Type:
1507-
if not isinstance(n.slice, Index):
1508-
self.fail(TYPE_COMMENT_SYNTAX_ERROR, self.line, getattr(n, 'col_offset', -1))
1509-
return AnyType(TypeOfAny.from_error)
1507+
1508+
if PY_MINOR_VERSION >= 9:
1509+
slice_value = n.slice
1510+
else:
1511+
if not isinstance(n.slice, Index):
1512+
self.fail(TYPE_COMMENT_SYNTAX_ERROR, self.line, getattr(n, 'col_offset', -1))
1513+
return AnyType(TypeOfAny.from_error)
1514+
slice_value = n.slice.value
15101515

15111516
empty_tuple_index = False
1512-
if isinstance(n.slice.value, ast3.Tuple):
1513-
params = self.translate_expr_list(n.slice.value.elts)
1514-
if len(n.slice.value.elts) == 0:
1517+
if isinstance(slice_value, ast3.Tuple):
1518+
params = self.translate_expr_list(slice_value.elts)
1519+
if len(slice_value.elts) == 0:
15151520
empty_tuple_index = True
15161521
else:
1517-
params = [self.visit(n.slice.value)]
1522+
params = [self.visit(slice_value)]
15181523

15191524
value = self.visit(n.value)
15201525
if isinstance(value, UnboundType) and not value.args:

0 commit comments

Comments
 (0)