Skip to content

Commit 8c9a7d7

Browse files
author
th3-j4ck4l
committed
Fixing issue 8627
1 parent d54fc8e commit 8c9a7d7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

mypy/fastparse.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,17 +1504,21 @@ 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+
if PY_MINOR_VERSION >= 9:
1508+
slice_value = n.slice
1509+
else:
1510+
if not isinstance(n.slice, Index):
1511+
self.fail(TYPE_COMMENT_SYNTAX_ERROR, self.line, getattr(n, 'col_offset', -1))
1512+
return AnyType(TypeOfAny.from_error)
1513+
slice_value = n.slice.value
15101514

15111515
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:
1516+
if isinstance(slice_value, ast3.Tuple):
1517+
params = self.translate_expr_list(slice_value.elts)
1518+
if len(slice_value.elts) == 0:
15151519
empty_tuple_index = True
15161520
else:
1517-
params = [self.visit(n.slice.value)]
1521+
params = [self.visit(slice_value)]
15181522

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

0 commit comments

Comments
 (0)