Skip to content

Commit

Permalink
Resolves python#8627
Browse files Browse the repository at this point in the history
  • Loading branch information
th3-j4ck4l committed Apr 6, 2020
1 parent d54fc8e commit deaaccf
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions mypy/fastparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1504,17 +1504,22 @@ def visit_Bytes(self, n: Bytes) -> Type:

# Subscript(expr value, slice slice, expr_context ctx)
def visit_Subscript(self, n: ast3.Subscript) -> Type:
if not isinstance(n.slice, Index):
self.fail(TYPE_COMMENT_SYNTAX_ERROR, self.line, getattr(n, 'col_offset', -1))
return AnyType(TypeOfAny.from_error)

if PY_MINOR_VERSION >= 9:
slice_value = n.slice
else:
if not isinstance(n.slice, Index):
self.fail(TYPE_COMMENT_SYNTAX_ERROR, self.line, getattr(n, 'col_offset', -1))
return AnyType(TypeOfAny.from_error)
slice_value = n.slice.value

empty_tuple_index = False
if isinstance(n.slice.value, ast3.Tuple):
params = self.translate_expr_list(n.slice.value.elts)
if len(n.slice.value.elts) == 0:
if isinstance(slice_value, ast3.Tuple):
params = self.translate_expr_list(slice_value.elts)
if len(slice_value.elts) == 0:
empty_tuple_index = True
else:
params = [self.visit(n.slice.value)]
params = [self.visit(slice_value)]

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

0 comments on commit deaaccf

Please sign in to comment.