Skip to content

Commit d683ada

Browse files
committed
Update newsfragment README.md and add newsfragment for 2556
1 parent 0f8a698 commit d683ada

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed
+1
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

+2
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

+23-12
Original file line numberDiff line numberDiff line change
@@ -672,13 +672,15 @@ def test_function_multiple_error_diagnoses(w3, arg1, arg2, diagnosis):
672672

673673

674674
@pytest.mark.parametrize(
675-
"address", (
675+
"address",
676+
(
676677
"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", # checksummed
677-
b'\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee', # noqa: E501
678-
)
678+
b"\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee", # noqa: E501
679+
),
679680
)
680681
def test_function_wrong_args_for_tuple_collapses_args_in_message(
681-
address, tuple_contract,
682+
address,
683+
tuple_contract,
682684
):
683685
with pytest.raises(ValidationError) as e:
684686
tuple_contract.functions.method(
@@ -687,18 +689,23 @@ def test_function_wrong_args_for_tuple_collapses_args_in_message(
687689

688690
# assert the user arguments are formatted as expected:
689691
# (int,(int,int),((int,(bool,(bool)),(address))))
690-
e.match("\\(int,\\(int,int\\),\\(\\(int,\\(bool,\\(bool\\)\\),\\(address\\)\\)\\)\\)") # noqa: E501
692+
e.match(
693+
"\\(int,\\(int,int\\),\\(\\(int,\\(bool,\\(bool\\)\\),\\(address\\)\\)\\)\\)"
694+
)
691695

692696
# assert the found method signature is formatted as expected:
693697
# ['method((uint256,uint256[],(int256,bool[2],address[])[]))']
694-
e.match("\\['method\\(\\(uint256,uint256\\[\\],\\(int256,bool\\[2\\],address\\[\\]\\)\\[\\]\\)\\)'\\]") # noqa: E501
698+
e.match(
699+
"\\['method\\(\\(uint256,uint256\\[\\],\\(int256,bool\\[2\\],address\\[\\]\\)\\[\\]\\)\\)'\\]" # noqa: E501
700+
)
695701

696702

697703
@pytest.mark.parametrize(
698-
"address", (
704+
"address",
705+
(
699706
"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", # checksummed
700-
b'\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee', # noqa: E501
701-
)
707+
b"\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee\xee", # noqa: E501
708+
),
702709
)
703710
def test_function_wrong_args_for_tuple_collapses_kwargs_in_message(
704711
address, tuple_contract
@@ -710,11 +717,15 @@ def test_function_wrong_args_for_tuple_collapses_kwargs_in_message(
710717

711718
# assert the user keyword arguments are formatted as expected:
712719
# {'a': '(int,(int,int),((int,(bool,(bool)),(address))))'}
713-
e.match("{'a': '\\(int,\\(int,int\\),\\(\\(int,\\(bool,\\(bool\\)\\),\\(address\\)\\)\\)\\)'}") # noqa: E501
720+
e.match(
721+
"{'a': '\\(int,\\(int,int\\),\\(\\(int,\\(bool,\\(bool\\)\\),\\(address\\)\\)\\)\\)'}" # noqa: E501
722+
)
714723

715724
# assert the found method signature is formatted as expected:
716725
# ['method((uint256,uint256[],(int256,bool[2],address[])[]))']
717-
e.match("\\['method\\(\\(uint256,uint256\\[\\],\\(int256,bool\\[2\\],address\\[\\]\\)\\[\\]\\)\\)'\\]") # noqa: E501
726+
e.match(
727+
"\\['method\\(\\(uint256,uint256\\[\\],\\(int256,bool\\[2\\],address\\[\\]\\)\\[\\]\\)\\)'\\]" # noqa: E501
728+
)
718729

719730

720731
def test_function_no_abi(w3):
@@ -1471,7 +1482,7 @@ async def test_async_accepts_block_hash_as_identifier(async_w3, async_math_contr
14711482
)
14721483
new = await async_math_contract.functions.counter().call(
14731484
block_identifier=more_blocks["result"][2]
1474-
) # noqa: E501
1485+
)
14751486

14761487
assert old == 0
14771488
assert new == 1

0 commit comments

Comments
 (0)