diff --git a/vyper/ast/parse.py b/vyper/ast/parse.py index b92c9d543c..21b801fd50 100644 --- a/vyper/ast/parse.py +++ b/vyper/ast/parse.py @@ -240,12 +240,10 @@ def visit_For(self, node): try: annotation = python_ast.parse(raw_annotation, mode="eval") - # call ASTTokens ctor for its side effects of enhancing the Python AST tree - # with token and source code information, specifically the `first_token` and - # `last_token` attributes that are accessed in `generic_visit`. - asttokens.ASTTokens( - raw_annotation, tree=cast(Optional[python_ast.Module], annotation) - ) + # enhance the Python AST tree with token and source code information, specifically the + # `first_token` and `last_token` attributes that are accessed in `generic_visit`. + tokens = asttokens.ASTTokens(raw_annotation) + tokens.mark_tokens(annotation) except SyntaxError as e: raise SyntaxException( "invalid type annotation", self._source_code, node.lineno, node.col_offset