Skip to content

Commit

Permalink
more clean up; fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Jan 10, 2024
1 parent 4259a9f commit 0126904
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
10 changes: 4 additions & 6 deletions vyper/ast/parse.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 3 additions & 5 deletions vyper/ast/pre_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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")
1 change: 0 additions & 1 deletion vyper/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 0126904

Please sign in to comment.