diff --git a/newsfragments/1954.feature.rst b/newsfragments/1954.feature.rst new file mode 100644 index 0000000000..e728f931ba --- /dev/null +++ b/newsfragments/1954.feature.rst @@ -0,0 +1 @@ +Add ``parity.set_mode``, deprecate ``parity.setMode`` diff --git a/web3/_utils/module_testing/parity_module.py b/web3/_utils/module_testing/parity_module.py index f8012a3686..923564c0b9 100644 --- a/web3/_utils/module_testing/parity_module.py +++ b/web3/_utils/module_testing/parity_module.py @@ -216,12 +216,16 @@ class ParitySetModuleTest: ] ) def test_set_mode(self, web3: "Web3", mode: ParityMode) -> None: - assert web3.parity.setMode(mode) is True + assert web3.parity.set_mode(mode) is True + + def test_set_mode_deprecated(self, web3: "Web3", mode: ParityMode) -> None: + with pytest.warns(DeprecationWarning, match="setMode is deprecated in favor of set_mode"): + assert web3.parity.setMode(mode) is True def test_set_mode_with_bad_string(self, web3: "Web3") -> None: with pytest.raises(InvalidParityMode, match="Couldn't parse parameters: mode"): # type ignored b/c it's an invalid literal ParityMode - web3.parity.setMode('not a mode') # type: ignore + web3.parity.set_mode('not a mode') # type: ignore def test_set_mode_with_no_argument(self, web3: "Web3") -> None: with pytest.raises( @@ -229,4 +233,4 @@ def test_set_mode_with_no_argument(self, web3: "Web3") -> None: match='Invalid params: invalid length 0, expected a tuple of size 1.' ): # type ignored b/c setMode expects arguments - web3.parity.setMode() # type: ignore + web3.parity.set_mode() # type: ignore diff --git a/web3/exceptions.py b/web3/exceptions.py index 86c1b2be1a..806d8f194f 100644 --- a/web3/exceptions.py +++ b/web3/exceptions.py @@ -213,6 +213,6 @@ class ContractLogicError(SolidityError, ValueError): class InvalidParityMode(TypeError, ValueError): # Inherits from TypeError for backwards compatibility """ - Raised when web3.parity.setMode() is called with no or invalid args + Raised when web3.parity.set_mode() is called with no or invalid args """ pass diff --git a/web3/parity.py b/web3/parity.py index 636581a0c6..d88954e9c5 100644 --- a/web3/parity.py +++ b/web3/parity.py @@ -210,7 +210,7 @@ def trace_transactions_munger( mungers=[trace_transactions_munger], ) - setMode: Method[Callable[[ParityMode], bool]] = Method( + set_mode: Method[Callable[[ParityMode], bool]] = Method( RPC.parity_setMode, mungers=[default_root_munger], ) @@ -226,6 +226,7 @@ def trace_transactions_munger( traceReplayTransaction = DeprecatedMethod(trace_replay_transaction, 'traceReplayTransaction', 'trace_replay_transaction') netPeers = DeprecatedMethod(net_peers, 'netPeers', 'net_peers') + setMode = DeprecatedMethod(set_mode, 'setMode', 'set_mode') traceBlock = DeprecatedMethod(trace_block, 'traceBlock', 'trace_block') traceFilter = DeprecatedMethod(trace_filter, 'traceFilter', 'trace_filter') traceReplayBlockTransactions = DeprecatedMethod(trace_replay_block_transactions,