diff --git a/web3/_utils/compat/__init__.py b/web3/_utils/compat/__init__.py index a7ff189319..dad55fc910 100644 --- a/web3/_utils/compat/__init__.py +++ b/web3/_utils/compat/__init__.py @@ -11,4 +11,5 @@ from typing_extensions import ( NotRequired, # py311 Self, # py311 + Unpack, # py311 ) diff --git a/web3/_utils/events.py b/web3/_utils/events.py index 812a5e5023..e1812e36b1 100644 --- a/web3/_utils/events.py +++ b/web3/_utils/events.py @@ -444,8 +444,8 @@ def deploy(self, w3: "Web3") -> "LogFilter": if not isinstance(w3, web3.Web3): raise Web3ValueError(f"Invalid web3 argument: got: {w3!r}") - for arg in AttributeDict.values(self.args): - arg._immutable = True # type: ignore[attr-defined] + for arg in self.args.values(): + arg._immutable = True self._immutable = True log_filter = cast("LogFilter", w3.eth.filter(self.filter_params)) diff --git a/web3/_utils/module_testing/eth_module.py b/web3/_utils/module_testing/eth_module.py index 558df11956..f536a42c88 100644 --- a/web3/_utils/module_testing/eth_module.py +++ b/web3/_utils/module_testing/eth_module.py @@ -220,7 +220,7 @@ async def test_eth_modify_transaction_legacy( txn_hash = await async_w3.eth.send_transaction(txn_params) modified_txn_hash = await async_w3.eth.modify_transaction( - txn_hash, gasPrice=(cast(int, txn_params["gasPrice"]) * 2), value=2 + txn_hash, gasPrice=(cast(Wei, txn_params["gasPrice"] * 2)), value=Wei(2) ) modified_txn = await async_w3.eth.get_transaction(modified_txn_hash) @@ -252,9 +252,9 @@ async def test_eth_modify_transaction( modified_txn_hash = await async_w3.eth.modify_transaction( txn_hash, - value=2, - maxPriorityFeePerGas=(cast(Wei, txn_params["maxPriorityFeePerGas"]) * 2), - maxFeePerGas=(cast(Wei, txn_params["maxFeePerGas"]) * 2), + value=Wei(2), + maxPriorityFeePerGas=(cast(Wei, txn_params["maxPriorityFeePerGas"] * 2)), + maxFeePerGas=(cast(Wei, txn_params["maxFeePerGas"] * 2)), ) modified_txn = await async_w3.eth.get_transaction(modified_txn_hash) @@ -3657,7 +3657,7 @@ def test_eth_modify_transaction_legacy( txn_hash = w3.eth.send_transaction(txn_params) modified_txn_hash = w3.eth.modify_transaction( - txn_hash, gasPrice=(cast(int, txn_params["gasPrice"]) * 2), value=2 + txn_hash, gasPrice=(cast(Wei, txn_params["gasPrice"] * 2)), value=Wei(2) ) modified_txn = w3.eth.get_transaction(modified_txn_hash) @@ -3686,9 +3686,9 @@ def test_eth_modify_transaction( modified_txn_hash = w3.eth.modify_transaction( txn_hash, - value=2, - maxPriorityFeePerGas=(cast(Wei, txn_params["maxPriorityFeePerGas"]) * 2), - maxFeePerGas=(cast(Wei, txn_params["maxFeePerGas"]) * 2), + value=Wei(2), + maxPriorityFeePerGas=(cast(Wei, txn_params["maxPriorityFeePerGas"] * 2)), + maxFeePerGas=(cast(Wei, txn_params["maxFeePerGas"] * 2)), ) modified_txn = w3.eth.get_transaction(modified_txn_hash) diff --git a/web3/eth/async_eth.py b/web3/eth/async_eth.py index 8e2e013b87..1c2ed35c8c 100644 --- a/web3/eth/async_eth.py +++ b/web3/eth/async_eth.py @@ -35,6 +35,9 @@ from web3._utils.blocks import ( select_method_for_block_identifier, ) +from web3._utils.compat import ( + Unpack, +) from web3._utils.fee_utils import ( async_fee_history_priority_fee, ) @@ -594,10 +597,8 @@ async def replace_transaction( self.w3, current_transaction, new_transaction ) - # todo: Update Any to stricter kwarg checking with TxParams - # https://github.com/python/mypy/issues/4441 async def modify_transaction( - self, transaction_hash: _Hash32, **transaction_params: Any + self, transaction_hash: _Hash32, **transaction_params: Unpack[TxParams] ) -> HexBytes: assert_valid_transaction_params(cast(TxParams, transaction_params)) diff --git a/web3/eth/eth.py b/web3/eth/eth.py index 89580dcecf..6db92a0091 100644 --- a/web3/eth/eth.py +++ b/web3/eth/eth.py @@ -30,6 +30,9 @@ from web3._utils.blocks import ( select_method_for_block_identifier, ) +from web3._utils.compat import ( + Unpack, +) from web3._utils.fee_utils import ( fee_history_priority_fee, ) @@ -596,10 +599,8 @@ def replace_transaction( current_transaction = get_required_transaction(self.w3, transaction_hash) return replace_transaction(self.w3, current_transaction, new_transaction) - # todo: Update Any to stricter kwarg checking with TxParams - # https://github.com/python/mypy/issues/4441 def modify_transaction( - self, transaction_hash: _Hash32, **transaction_params: Any + self, transaction_hash: _Hash32, **transaction_params: Unpack[TxParams] ) -> HexBytes: assert_valid_transaction_params(cast(TxParams, transaction_params)) current_transaction = get_required_transaction(self.w3, transaction_hash)