Skip to content

Commit ea50d26

Browse files
committed
Update newsfragment README.md and add newsfragment for 2556
1 parent ed68c2b commit ea50d26

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Provide better messaging to wrong arguments for contract functions, especially for ``tuple`` argument types.

newsfragments/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ relevant to people working on the code itself.)
1212
* `bugfix`
1313
* `doc`
1414
* `misc`
15+
* `breaking-change`
16+
* `deprecation`
1517

1618
So for example: `123.feature.rst`, `456.bugfix.rst`
1719

tests/core/contracts/test_contract_call_interface.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -670,13 +670,15 @@ def test_function_multiple_error_diagnoses(w3, arg1, arg2, diagnosis):
670670

671671

672672
@pytest.mark.parametrize(
673-
"address", (
673+
"address",
674+
(
674675
"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", # checksummed
675-
b'\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee', # noqa: E501
676-
)
676+
b"\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee", # noqa: E501
677+
),
677678
)
678679
def test_function_wrong_args_for_tuple_collapses_args_in_message(
679-
address, tuple_contract,
680+
address,
681+
tuple_contract,
680682
):
681683
with pytest.raises(ValidationError) as e:
682684
tuple_contract.functions.method(
@@ -685,18 +687,23 @@ def test_function_wrong_args_for_tuple_collapses_args_in_message(
685687

686688
# assert the user arguments are formatted as expected:
687689
# (int,(int,int),((int,(bool,(bool)),(address))))
688-
e.match("\\(int,\\(int,int\\),\\(\\(int,\\(bool,\\(bool\\)\\),\\(address\\)\\)\\)\\)") # noqa: E501
690+
e.match(
691+
"\\(int,\\(int,int\\),\\(\\(int,\\(bool,\\(bool\\)\\),\\(address\\)\\)\\)\\)"
692+
)
689693

690694
# assert the found method signature is formatted as expected:
691695
# ['method((uint256,uint256[],(int256,bool[2],address[])[]))']
692-
e.match("\\['method\\(\\(uint256,uint256\\[\\],\\(int256,bool\\[2\\],address\\[\\]\\)\\[\\]\\)\\)'\\]") # noqa: E501
696+
e.match(
697+
"\\['method\\(\\(uint256,uint256\\[\\],\\(int256,bool\\[2\\],address\\[\\]\\)\\[\\]\\)\\)'\\]" # noqa: E501
698+
)
693699

694700

695701
@pytest.mark.parametrize(
696-
"address", (
702+
"address",
703+
(
697704
"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", # checksummed
698-
b'\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee', # noqa: E501
699-
)
705+
b"\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee", # noqa: E501
706+
),
700707
)
701708
def test_function_wrong_args_for_tuple_collapses_kwargs_in_message(
702709
address, tuple_contract
@@ -708,11 +715,15 @@ def test_function_wrong_args_for_tuple_collapses_kwargs_in_message(
708715

709716
# assert the user keyword arguments are formatted as expected:
710717
# {'a': '(int,(int,int),((int,(bool,(bool)),(address))))'}
711-
e.match("{'a': '\\(int,\\(int,int\\),\\(\\(int,\\(bool,\\(bool\\)\\),\\(address\\)\\)\\)\\)'}") # noqa: E501
718+
e.match(
719+
"{'a': '\\(int,\\(int,int\\),\\(\\(int,\\(bool,\\(bool\\)\\),\\(address\\)\\)\\)\\)'}" # noqa: E501
720+
)
712721

713722
# assert the found method signature is formatted as expected:
714723
# ['method((uint256,uint256[],(int256,bool[2],address[])[]))']
715-
e.match("\\['method\\(\\(uint256,uint256\\[\\],\\(int256,bool\\[2\\],address\\[\\]\\)\\[\\]\\)\\)'\\]") # noqa: E501
724+
e.match(
725+
"\\['method\\(\\(uint256,uint256\\[\\],\\(int256,bool\\[2\\],address\\[\\]\\)\\[\\]\\)\\)'\\]" # noqa: E501
726+
)
716727

717728

718729
def test_function_no_abi(w3):
@@ -1469,7 +1480,7 @@ async def test_async_accepts_block_hash_as_identifier(async_w3, async_math_contr
14691480
)
14701481
new = await async_math_contract.functions.counter().call(
14711482
block_identifier=more_blocks["result"][2]
1472-
) # noqa: E501
1483+
)
14731484

14741485
assert old == 0
14751486
assert new == 1

0 commit comments

Comments
 (0)