Skip to content

Commit

Permalink
Fixed lint errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
saikat041 committed Sep 25, 2020
1 parent aacff09 commit 80f416b
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/functional/codegen/test_struct_return.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest


@pytest.mark.parametrize("string", ["a", "abc", "abcde", "potato"])
def test_string_inside_tuple(get_contract, string):
code = f"""
Expand Down Expand Up @@ -28,4 +29,3 @@ def test_values(a: address) -> Person:

c2 = get_contract(code)
assert c2.test_values(c1.address) == [string, 42]

3 changes: 2 additions & 1 deletion tests/functional/codegen/test_tuple_return.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest


@pytest.mark.parametrize("string", ["a", "abc", "abcde", "potato"])
def test_string_inside_tuple(get_contract, string):
code = f"""
Expand Down Expand Up @@ -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]
assert c2.test_values(c1.address) == [bytes(string, "utf-8"), 42]
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion vyper/codegen/abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions vyper/codegen/return_.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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]
Expand Down
5 changes: 2 additions & 3 deletions vyper/parser/parser_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
ByteArrayType,
ListType,
MappingType,
StringType,
StructType,
TupleLike,
TupleType,
Expand Down Expand Up @@ -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",
)
Expand Down
1 change: 1 addition & 0 deletions vyper/parser/self_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
StateAccessViolation,
StructureException,
TypeMismatch,
TypeCheckFailure
)
from vyper.parser.lll_node import LLLnode
from vyper.parser.parser_utils import getpos, pack_arguments
Expand Down

0 comments on commit 80f416b

Please sign in to comment.