From 729df1ec44422b363d36d4f71945a98e1b9b86be Mon Sep 17 00:00:00 2001 From: tserg <8017125+tserg@users.noreply.github.com> Date: Sat, 21 Sep 2024 20:39:54 +0800 Subject: [PATCH] fix lint --- vyper/builtins/_signatures.py | 8 +++++--- vyper/builtins/functions.py | 6 ------ vyper/semantics/types/base.py | 2 +- vyper/semantics/types/function.py | 4 +++- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/vyper/builtins/_signatures.py b/vyper/builtins/_signatures.py index d0fba87e74..f748eac8de 100644 --- a/vyper/builtins/_signatures.py +++ b/vyper/builtins/_signatures.py @@ -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 diff --git a/vyper/builtins/functions.py b/vyper/builtins/functions.py index 291d8c3f8a..11a2ce1570 100644 --- a/vyper/builtins/functions.py +++ b/vyper/builtins/functions.py @@ -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 diff --git a/vyper/semantics/types/base.py b/vyper/semantics/types/base.py index b778670f37..4f7e462d5f 100644 --- a/vyper/semantics/types/base.py +++ b/vyper/semantics/types/base.py @@ -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) diff --git a/vyper/semantics/types/function.py b/vyper/semantics/types/function.py index 856f4820e8..0eee4a7e01 100644 --- a/vyper/semantics/types/function.py +++ b/vyper/semantics/types/function.py @@ -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)