Skip to content

Commit 87df173

Browse files
committed
Explicit assignment of user_message kwarg, disallow kwargs in general
1 parent b1887d8 commit 87df173

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tests/core/exceptions/test_exceptions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ def test_web3exception_with_user_message():
1313

1414

1515
def test_web3exception_with_kwargs():
16-
with pytest.raises(Web3Exception) as exception:
16+
with pytest.raises(TypeError) as exception:
1717
raise Web3Exception(data={"message": "Unable to fulfill your request."})
18-
assert exception.type is Web3Exception
19-
assert exception.value.user_message is None
18+
assert exception.type is TypeError
19+
assert hasattr(exception.value, "data") is False
2020
assert (
21-
exception.value.kwargs["data"]["message"] == "Unable to fulfill your request."
21+
str(exception.value) == "__init__() got an unexpected keyword argument 'data'"
2222
)
2323

2424

web3/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ def __init__(
3434
self,
3535
*args: Any,
3636
user_message: Optional[str] = None,
37-
**kwargs: Any,
3837
):
3938
super().__init__(*args)
39+
4040
# Assign properties of Web3Exception
41-
self.__dict__.update(locals())
41+
self.user_message = user_message
4242

4343

4444
class BadFunctionCallOutput(Web3Exception):

0 commit comments

Comments
 (0)