Skip to content

Commit

Permalink
replace ctor with mark_tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Jan 7, 2024
1 parent 54c31b8 commit ef7841f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions vyper/ast/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ef7841f

Please sign in to comment.