From 2a95ec28d8a922a5ee78cfbb4a406b8b4a3ae982 Mon Sep 17 00:00:00 2001 From: kclowes Date: Fri, 23 Apr 2021 15:51:54 -0600 Subject: [PATCH] Parity setMode to snake --- newsfragments/1954.feature.rst | 1 + web3/_utils/module_testing/parity_module.py | 10 +++++++--- web3/exceptions.py | 2 +- web3/parity.py | 3 ++- 4 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 newsfragments/1954.feature.rst 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 249b910e54..c054c7bbae 100644 --- a/web3/_utils/module_testing/parity_module.py +++ b/web3/_utils/module_testing/parity_module.py @@ -167,12 +167,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( @@ -180,4 +184,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 e75416bc88..ebc44b8925 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], ) @@ -224,3 +224,4 @@ 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')