From 80f416bd7832c1e538e728d7e00423c7ff296095 Mon Sep 17 00:00:00 2001 From: Saikat Date: Fri, 25 Sep 2020 19:02:40 +0530 Subject: [PATCH] Fixed lint errors. --- tests/functional/codegen/test_struct_return.py | 2 +- tests/functional/codegen/test_tuple_return.py | 3 ++- .../external_contracts/test_external_contract_calls.py | 1 + vyper/codegen/abi.py | 3 ++- vyper/codegen/return_.py | 6 +++--- vyper/parser/parser_utils.py | 5 ++--- vyper/parser/self_call.py | 1 + 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/functional/codegen/test_struct_return.py b/tests/functional/codegen/test_struct_return.py index 04e2d61e3ec..fdc67dc1bec 100644 --- a/tests/functional/codegen/test_struct_return.py +++ b/tests/functional/codegen/test_struct_return.py @@ -1,5 +1,6 @@ import pytest + @pytest.mark.parametrize("string", ["a", "abc", "abcde", "potato"]) def test_string_inside_tuple(get_contract, string): code = f""" @@ -28,4 +29,3 @@ def test_values(a: address) -> Person: c2 = get_contract(code) assert c2.test_values(c1.address) == [string, 42] - diff --git a/tests/functional/codegen/test_tuple_return.py b/tests/functional/codegen/test_tuple_return.py index 8727e5793f7..670076cc247 100644 --- a/tests/functional/codegen/test_tuple_return.py +++ b/tests/functional/codegen/test_tuple_return.py @@ -1,5 +1,6 @@ import pytest + @pytest.mark.parametrize("string", ["a", "abc", "abcde", "potato"]) def test_string_inside_tuple(get_contract, string): code = f""" @@ -41,4 +42,4 @@ def test_values(a: address) -> (Bytes[6], uint256): """ c2 = get_contract(code) - assert c2.test_values(c1.address) == [bytes(string, "utf-8"), 42] \ No newline at end of file + assert c2.test_values(c1.address) == [bytes(string, "utf-8"), 42] diff --git a/tests/parser/features/external_contracts/test_external_contract_calls.py b/tests/parser/features/external_contracts/test_external_contract_calls.py index 88851bd7f08..3f36414b090 100644 --- a/tests/parser/features/external_contracts/test_external_contract_calls.py +++ b/tests/parser/features/external_contracts/test_external_contract_calls.py @@ -828,6 +828,7 @@ def test(addr: address) -> (int128, address): assert c1.out_literals() == [1, "0x0000000000000000000000000000000000012345"] assert c2.test(c1.address) == list(c1.out_literals()) + def test_struct_return_external_contract_call_2(get_contract_with_gas_estimation): contract_1 = """ struct X: diff --git a/vyper/codegen/abi.py b/vyper/codegen/abi.py index d5eeb53a2cd..9a5df3987b6 100644 --- a/vyper/codegen/abi.py +++ b/vyper/codegen/abi.py @@ -416,7 +416,8 @@ def abi_decode(lll_node, src, pos=None): src_loc = LLLnode("src_loc", typ=o.typ, location=src.location) if parent_abi_t.is_tuple(): if abi_t.is_dynamic(): - child_loc = LLLnode.from_list(["add", "src", unwrap_location(src_loc)], typ=o.typ, location=src.location) + child_loc = ["add", "src", unwrap_location(src_loc)] + child_loc = LLLnode.from_list(child_loc, typ=o.typ, location=src.location) else: child_loc = src_loc # descend into the child tuple diff --git a/vyper/codegen/return_.py b/vyper/codegen/return_.py index 719f1eab8b3..374e70c2990 100644 --- a/vyper/codegen/return_.py +++ b/vyper/codegen/return_.py @@ -1,6 +1,6 @@ from vyper.parser.lll_node import LLLnode -from vyper.parser.parser_utils import getpos, zero_pad -from vyper.types import BaseType, ByteArrayLike, get_size_of_type +from vyper.parser.parser_utils import getpos +from vyper.types import BaseType from vyper.types.check import check_assign from vyper.utils import MemoryPositions @@ -86,7 +86,7 @@ def gen_tuple_return(stmt, context, sub): check_assign(return_buffer, sub, pos=getpos(stmt)) # in case of multi we can't create a variable to store location of the return expression - # as multi can have data from multiple location like store, calldata etc + # as multi can have data from multiple location like store, calldata etc if sub.value == "multi": encode_out = abi_encode(return_buffer, sub, pos=getpos(stmt), returns=True) load_return_len = ["mload", MemoryPositions.FREE_VAR_SPACE] diff --git a/vyper/parser/parser_utils.py b/vyper/parser/parser_utils.py index 23d32aef4ce..f4d3782323d 100644 --- a/vyper/parser/parser_utils.py +++ b/vyper/parser/parser_utils.py @@ -15,7 +15,6 @@ ByteArrayType, ListType, MappingType, - StringType, StructType, TupleLike, TupleType, @@ -713,13 +712,13 @@ def make_setter(left, right, location, pos, in_function_call=False): for left_arg, key, loc in zip(left.args, keyz, locations): subs.append( make_setter( - left_arg, + left_arg, add_variable_offset(right_token, key, pos=pos), loc, pos=pos ) ) - + return LLLnode.from_list( ["with", "_R", right, ["seq"] + subs], typ=None, annotation="Tuple assignment", ) diff --git a/vyper/parser/self_call.py b/vyper/parser/self_call.py index 016426c474c..2a42f9351aa 100644 --- a/vyper/parser/self_call.py +++ b/vyper/parser/self_call.py @@ -4,6 +4,7 @@ StateAccessViolation, StructureException, TypeMismatch, + TypeCheckFailure ) from vyper.parser.lll_node import LLLnode from vyper.parser.parser_utils import getpos, pack_arguments