Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Sep 21, 2024
1 parent 1b25514 commit 729df1e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
8 changes: 5 additions & 3 deletions vyper/builtins/_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,15 @@ def _validate_arg_types(self, node: vy_ast.Call) -> None:
def check_modifiability_for_call(self, node: vy_ast.Call, modifiability: Modifiability) -> bool:
return self._modifiability <= modifiability

def get_return_type(self, node: vy_ast.Call, expected_type: VyperType | None = None) -> Optional[VyperType]:
def get_return_type(
self, node: vy_ast.Call, expected_type: Optional[VyperType] = None
) -> Optional[VyperType]:
self._validate_arg_types(node)

ret = self._return_type

if expected_type is not None and not expected_type.compare_type(ret):
raise TypeMismatch("{self._id}() returns {ret}, but expected {expected_type}", node)
if expected_type is not None and not expected_type.compare_type(ret): # type: ignore
raise TypeMismatch(f"{self._id}() returns {ret}, but expected {expected_type}", node)

return ret

Expand Down
6 changes: 0 additions & 6 deletions vyper/builtins/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1996,12 +1996,6 @@ def infer_arg_types(self, node, expected_return_type=None):

return types_list

def infer_arg_types(self, node, expected_return_typ=None):
types_list = self.fetch_call_return(node)
# type mismatch should have been caught in `fetch_call_return`
assert expected_return_typ in types_list
return [expected_return_typ, expected_return_typ]

@process_inputs
def build_IR(self, expr, args, kwargs, context):
op = self._opcode
Expand Down
2 changes: 1 addition & 1 deletion vyper/semantics/types/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def check_modifiability_for_call(self, node, modifiability):
def get_return_type(self, node, expected_type=None):
if expected_type is not None:
if not self.typedef.compare_type(expected_type):
raise CompilerPanic("bad type passed to {self.typedef} ctor", node)
raise CompilerPanic(f"bad type passed to {self.typedef} ctor", node)
if hasattr(self.typedef, "_ctor_call_return"):
return self.typedef._ctor_call_return(node)
raise StructureException("Value is not callable", node)
Expand Down
4 changes: 3 additions & 1 deletion vyper/semantics/types/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,9 @@ def _enhance_call_exception(self, e, ast_node=None):
e.hint = self._pp_signature
return e

def get_return_type(self, node: vy_ast.Call, expected_type: VyperType | None = None) -> Optional[VyperType]:
def get_return_type(
self, node: vy_ast.Call, expected_type: VyperType | None = None
) -> Optional[VyperType]:
# mypy hint - right now, the only way a ContractFunctionT can be
# called is via `Attribute`, e.x. self.foo() or library.bar()
assert isinstance(node.func, vy_ast.Attribute)
Expand Down

0 comments on commit 729df1e

Please sign in to comment.