diff --git a/vyper/ast/parse.py b/vyper/ast/parse.py index e0bd86e352..b1b9a8d917 100644 --- a/vyper/ast/parse.py +++ b/vyper/ast/parse.py @@ -1,7 +1,6 @@ import ast as python_ast import string import tokenize - from decimal import Decimal from typing import Any, Dict, List, Optional, Union, cast @@ -141,7 +140,6 @@ def __init__( self.counter: int = 0 - def generic_visit(self, node): """ Annotate a node with information that simplifies Vyper node generation. @@ -275,14 +273,14 @@ def _add_pair(x, y): start=_add_pair(n.first_token.start, adjustment), end=_add_pair(n.first_token.end, adjustment), startpos=n.first_token.startpos + og_target.first_token.startpos, - endpos=n.first_token.startpos + og_target.first_token.startpos + endpos=n.first_token.startpos + og_target.first_token.startpos, ) if hasattr(n, "last_token"): n.last_token = n.last_token._replace( start=_add_pair(n.last_token.start, adjustment), end=_add_pair(n.last_token.end, adjustment), startpos=n.last_token.startpos + og_target.first_token.startpos, - endpos=n.last_token.endpos + og_target.first_token.startpos + endpos=n.last_token.endpos + og_target.first_token.startpos, ) node.target = annotation @@ -448,8 +446,8 @@ def annotate_python_ast( source_code : str The originating source code of the AST. loop_var_annotations: dict, optional - A mapping of line numbers of `For` nodes to the type annotation of the iterator - extracted during pre-parsing. + A mapping of line numbers of `For` nodes to the tokens of the type annotation + of the iterator extracted during pre-parsing. modification_offsets : dict, optional A mapping of class names to their original class types. diff --git a/vyper/ast/pre_parser.py b/vyper/ast/pre_parser.py index fc458cb9cc..f7d2df208a 100644 --- a/vyper/ast/pre_parser.py +++ b/vyper/ast/pre_parser.py @@ -141,8 +141,9 @@ def pre_parse(code: str) -> tuple[Settings, ModificationOffsets, dict, str]: Compilation settings based on the directives in the source code ModificationOffsets A mapping of class names to their original class types. - dict[tuple[int, int], str] - A mapping of line/column offsets of `For` nodes to the annotation of the for loop target + dict[tuple[int, int], list[TokenInfo]] + A mapping of line/column offsets of `For` nodes to the tokens of the annotation of the + for loop target str Reformatted python source string. """ @@ -225,9 +226,6 @@ def pre_parse(code: str) -> tuple[Settings, ModificationOffsets, dict, str]: for_loop_annotations = {} for k, v in for_parser.annotations.items(): - #v_source = untokenize(v) - # untokenize adds backslashes and whitespace, strip them. - #v_source = v_source.replace("\\", "").strip() for_loop_annotations[k] = v.copy() return settings, modification_offsets, for_loop_annotations, untokenize(result).decode("utf-8") diff --git a/vyper/exceptions.py b/vyper/exceptions.py index e42afe4710..51f3fea14c 100644 --- a/vyper/exceptions.py +++ b/vyper/exceptions.py @@ -106,7 +106,6 @@ def __str__(self): line_numbers=VYPER_ERROR_LINE_NUMBERS, ) except Exception: - print("EXC", node.full_source_code, node.node_source_code, node.lineno, node.col_offset) # necessary for certain types of syntax exceptions return self.message