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

Snakecase clientVersion #2686

Merged
merged 3 commits into from
Oct 27, 2022
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
4 changes: 2 additions & 2 deletions docs/middleware.rst
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ The easiest way to connect to a default ``geth --dev`` instance which loads the
>>> from web3.auto.gethdev import w3

# confirm that the connection succeeded
>>> w3.clientVersion
>>> w3.client_version
'Geth/v1.7.3-stable-4bb3c89d/linux-amd64/go1.9'

This example connects to a local ``geth --dev`` instance on Linux with a
Expand All @@ -408,7 +408,7 @@ unique IPC location and loads the middleware:
>>> w3.middleware_onion.inject(geth_poa_middleware, layer=0)

# confirm that the connection succeeded
>>> w3.clientVersion
>>> w3.client_version
'Geth/v1.7.3-stable-4bb3c89d/linux-amd64/go1.9'

Why is ``geth_poa_middleware`` necessary?
Expand Down
4 changes: 2 additions & 2 deletions docs/providers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ For example, the following retrieves the client enode endpoint for both geth and

connected = w3.is_connected()

if connected and w3.clientVersion.startswith('Parity'):
if connected and w3.client_version.startswith('Parity'):
enode = w3.parity.enode

elif connected and w3.clientVersion.startswith('Geth'):
elif connected and w3.client_version.startswith('Geth'):
enode = w3.geth.admin.node_info['enode']

else:
Expand Down
4 changes: 2 additions & 2 deletions docs/web3.main.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ Attributes
>>> web3.api
"4.7.0"

.. py:attribute:: Web3.clientVersion
.. py:attribute:: Web3.client_version

* Delegates to ``web3_clientVersion`` RPC Method

Returns the current client version.

.. code-block:: python

>>> web3.clientVersion
>>> web3.client_version
'Geth/v1.4.11-stable-fed692f6/darwin/go1.7'


Expand Down
1 change: 1 addition & 0 deletions newsfragments/2686.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Snakecase the clientVersion method
2 changes: 1 addition & 1 deletion tests/core/version-module/test_version_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ def test_legacy_version_deprecation(blocking_w3):
async def test_async_blocking_version(async_w3, blocking_w3):
assert async_w3.async_version.api == blocking_w3.api

assert await async_w3.async_version.node == blocking_w3.clientVersion
assert await async_w3.async_version.node == blocking_w3.client_version
2 changes: 0 additions & 2 deletions tests/core/web3-module/test_clientVersion.py

This file was deleted.

2 changes: 2 additions & 0 deletions tests/core/web3-module/test_client_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_web3_client_version(w3):
assert w3.client_version.startswith("EthereumTester/")
2 changes: 1 addition & 1 deletion tests/integration/go_ethereum/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


class GoEthereumTest(Web3ModuleTest):
def _check_web3_clientVersion(self, client_version):
def _check_web3_client_version(self, client_version):
assert client_version.startswith("Geth/")


Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_ethereum_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def funded_account_for_raw_txn(w3):


class TestEthereumTesterWeb3Module(Web3ModuleTest):
def _check_web3_clientVersion(self, client_version):
def _check_web3_client_version(self, client_version):
assert client_version.startswith("EthereumTester/")


Expand Down
8 changes: 4 additions & 4 deletions web3/_utils/module_testing/web3_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@


class Web3ModuleTest:
def test_web3_clientVersion(self, w3: Web3) -> None:
client_version = w3.clientVersion
self._check_web3_clientVersion(client_version)
def test_web3_client_version(self, w3: Web3) -> None:
client_version = w3.client_version
self._check_web3_client_version(client_version)

def _check_web3_clientVersion(self, client_version: str) -> NoReturn:
def _check_web3_client_version(self, client_version: str) -> NoReturn:
raise NotImplementedError("Must be implemented by subclasses")

# Contract that calculated test values can be found at
Expand Down
2 changes: 1 addition & 1 deletion web3/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def provider(self, provider: Union[BaseProvider, AsyncBaseProvider]) -> None:
self.manager.provider = provider

@property
def clientVersion(self) -> str:
def client_version(self) -> str:
return self.manager.request_blocking(RPC.web3_clientVersion, [])

@property
Expand Down
3 changes: 2 additions & 1 deletion web3/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def api(self) -> NoReturn:
@property
def node(self) -> NoReturn:
raise DeprecationWarning(
"This method has been deprecated ... Please use web3.clientVersion instead."
"This method has been deprecated ... "
"Please use web3.client_version instead."
)

@property
Expand Down