Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Nov 14, 2023
1 parent 78bad6c commit 524fb8f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
6 changes: 3 additions & 3 deletions vyper/ast/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ def prefold(self) -> Optional[ExprNode]:
elements = [e._metadata.get("folded_value") for e in self.elements]
if None not in elements:
return type(self).from_node(self, elements=elements)

return None


Expand Down Expand Up @@ -925,7 +925,7 @@ def prefold(self) -> Optional[ExprNode]:
if operand is not None:
value = self.op._op(operand.value)
return type(operand).from_node(self, value=value)

return None

def evaluate(self) -> ExprNode:
Expand Down Expand Up @@ -1204,7 +1204,7 @@ def prefold(self) -> Optional[ExprNode]:

if None in (left, right):
return None

value = self.op._op(left.value, right.value)
return NameConstant.from_node(self, value=value)

Expand Down
2 changes: 1 addition & 1 deletion vyper/builtins/_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _validate_arg_types(self, node):
def prefold(self, node):
if not hasattr(self, "evaluate"):
return None

try:
return self.evaluate(node)
except (UnfoldableNode, VyperException):
Expand Down
5 changes: 1 addition & 4 deletions vyper/builtins/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
StructureException,
TypeMismatch,
UnfoldableNode,
VyperException,
ZeroDivisionException,
)
from vyper.semantics.analysis.base import VarInfo
Expand Down Expand Up @@ -991,9 +990,7 @@ def get_denomination(self, node):
try:
denom = next(v for k, v in self.wei_denoms.items() if value.value in k)
except StopIteration:
raise ArgumentException(
f"Unknown denomination: {value.value}", node.args[1]
) from None
raise ArgumentException(f"Unknown denomination: {value.value}", node.args[1]) from None

return denom

Expand Down
7 changes: 5 additions & 2 deletions vyper/compiler/phases.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CompilerData:
vyper_module : vy_ast.Module
Top-level Vyper AST node
vyper_module_annotated : vy_ast.Module
Annotated but unfolded Vyper AST
Annotated but unfolded Vyper AST
vyper_module_folded : vy_ast.Module
Annotated and folded Vyper AST
global_ctx : GlobalContext
Expand Down Expand Up @@ -139,7 +139,10 @@ def vyper_module_annotated(self) -> vy_ast.Module:
@cached_property
def _folded_module(self):
return generate_folded_ast(
self.contract_path, self.vyper_module_annotated, self.input_bundle, self.storage_layout_override
self.contract_path,
self.vyper_module_annotated,
self.input_bundle,
self.storage_layout_override,
)

@property
Expand Down
12 changes: 11 additions & 1 deletion vyper/semantics/analysis/pre_typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,17 @@ def pre_typecheck(node: vy_ast.Module):


def prefold(node: vy_ast.VyperNode, constants: dict) -> None:
if isinstance(node, (vy_ast.BinOp, vy_ast.BoolOp, vy_ast.Compare, vy_ast.List, vy_ast.Subscript, vy_ast.UnaryOp)):
if isinstance(
node,
(
vy_ast.BinOp,
vy_ast.BoolOp,
vy_ast.Compare,
vy_ast.List,
vy_ast.Subscript,
vy_ast.UnaryOp,
),
):
node._metadata["folded_value"] = node.prefold()

if isinstance(node, vy_ast.Name):
Expand Down

0 comments on commit 524fb8f

Please sign in to comment.