Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parity setMode to snake #1954

Merged
merged 1 commit into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/1954.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``parity.set_mode``, deprecate ``parity.setMode``
10 changes: 7 additions & 3 deletions web3/_utils/module_testing/parity_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,21 @@ 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(
InvalidParityMode,
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
2 changes: 1 addition & 1 deletion web3/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion web3/parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)
Expand All @@ -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,
Expand Down