Skip to content

Commit 12b649d

Browse files
authored
snakecase isConnected (#2643)
1 parent 76f9b6c commit 12b649d

File tree

18 files changed

+40
-39
lines changed

18 files changed

+40
-39
lines changed

docs/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ virtualenv for smoke testing:
381381
$ pip install ipython
382382
$ ipython
383383
>>> from web3.auto import w3
384-
>>> w3.isConnected()
384+
>>> w3.is_connected()
385385
>>> ...
386386
387387

docs/internals.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ setting the middlewares the provider should use.
101101
the JSON-RPC method being called.
102102

103103

104-
.. py:method:: BaseProvider.isConnected()
104+
.. py:method:: BaseProvider.is_connected()
105105
106106
This function should return ``True`` or ``False`` depending on whether the
107107
provider should be considered *connected*. For example, an IPC socket

docs/overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ following built-in providers:
4040
# WebsocketProvider:
4141
>>> w3 = Web3(Web3.WebsocketProvider('ws://127.0.0.1:8546'))
4242
43-
>>> w3.isConnected()
43+
>>> w3.is_connected()
4444
True
4545
4646
For more information, (e.g., connecting to remote nodes, provider auto-detection,

docs/providers.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ For example, the following retrieves the client enode endpoint for both geth and
132132
133133
from web3.auto import w3
134134
135-
connected = w3.isConnected()
135+
connected = w3.is_connected()
136136
137137
if connected and w3.clientVersion.startswith('Parity'):
138138
enode = w3.parity.enode
@@ -186,7 +186,7 @@ an optional secret key, set the environment variable ``WEB3_INFURA_API_SECRET``:
186186
>>> from web3.auto.infura import w3
187187
188188
# confirm that the connection succeeded
189-
>>> w3.isConnected()
189+
>>> w3.is_connected()
190190
True
191191
192192
Geth dev Proof of Authority
@@ -199,7 +199,7 @@ To connect to a ``geth --dev`` Proof of Authority instance with defaults:
199199
>>> from web3.auto.gethdev import w3
200200
201201
# confirm that the connection succeeded
202-
>>> w3.isConnected()
202+
>>> w3.is_connected()
203203
True
204204
205205
Built In Providers

docs/quickstart.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Web3.py makes this test provider available via ``EthereumTesterProvider``:
4646
4747
>>> from web3 import Web3, EthereumTesterProvider
4848
>>> w3 = Web3(EthereumTesterProvider())
49-
>>> w3.isConnected()
49+
>>> w3.is_connected()
5050
True
5151
5252
@@ -73,7 +73,7 @@ to this local node can be done as follows:
7373
# WebsocketProvider:
7474
>>> w3 = Web3(Web3.WebsocketProvider('wss://127.0.0.1:8546'))
7575
76-
>>> w3.isConnected()
76+
>>> w3.is_connected()
7777
True
7878
7979
If you stick to the default ports or IPC file locations, you can utilize a
@@ -83,7 +83,7 @@ and save a few keystrokes:
8383
.. code-block:: python
8484
8585
>>> from web3.auto import w3
86-
>>> w3.isConnected()
86+
>>> w3.is_connected()
8787
True
8888
8989

docs/troubleshooting.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Ethereum network. An example configuration, if you're connecting to a locally ru
5555
>>> w3 = Web3(Web3.HTTPProvider('http://localhost:8545'))
5656
5757
# now `w3` is available to use:
58-
>>> w3.isConnected()
58+
>>> w3.is_connected()
5959
True
6060
>>> w3.eth.send_transaction(...)
6161
@@ -66,11 +66,11 @@ Refer to the :ref:`providers` documentation for further help with configuration.
6666

6767
Why isn't my web3 instance connecting to the network?
6868
-----------------------------------------------------
69-
You can check that your instance is connected via the ``isConnected`` method:
69+
You can check that your instance is connected via the ``is_connected`` method:
7070

7171
.. code-block:: python
7272
73-
>>> w3.isConnected()
73+
>>> w3.is_connected()
7474
False
7575
7676
There's a variety of explanations for why you may see ``False`` here. If you're
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Snakecase the `isConnected` method

tests/core/providers/test_async_tester_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@pytest.mark.asyncio
99
async def test_async_tester_provider_is_connected() -> None:
1010
provider = AsyncEthereumTesterProvider()
11-
connected = await provider.isConnected()
11+
connected = await provider.is_connected()
1212
assert connected
1313

1414

tests/core/providers/test_ipc_provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ def jsonrpc_ipc_pipe_path():
3333

3434
def test_ipc_no_path():
3535
"""
36-
IPCProvider.isConnected() returns False when no path is supplied
36+
IPCProvider.is_connected() returns False when no path is supplied
3737
"""
3838
ipc = IPCProvider(None)
39-
assert ipc.isConnected() is False
39+
assert ipc.is_connected() is False
4040

4141

4242
def test_ipc_tilda_in_path():

tests/core/providers/test_provider.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@
66

77

88
class ConnectedProvider(BaseProvider):
9-
def isConnected(self):
9+
def is_connected(self):
1010
return True
1111

1212

1313
class DisconnectedProvider(BaseProvider):
14-
def isConnected(self):
14+
def is_connected(self):
1515
return False
1616

1717

18-
def test_isConnected_connected():
18+
def test_is_connected_connected():
1919
"""
20-
Web3.isConnected() returns True when connected to a node.
20+
Web3.is_connected() returns True when connected to a node.
2121
"""
2222
w3 = Web3(ConnectedProvider())
23-
assert w3.isConnected() is True
23+
assert w3.is_connected() is True
2424

2525

26-
def test_isConnected_disconnected():
26+
def test_is_connected_disconnected():
2727
"""
28-
Web3.isConnected() returns False when configured with a provider
28+
Web3.is_connected() returns False when configured with a provider
2929
that's not connected to a node.
3030
"""
3131
w3 = Web3(DisconnectedProvider())
32-
assert w3.isConnected() is False
32+
assert w3.is_connected() is False
3333

3434

3535
def test_autoprovider_detection():
@@ -50,6 +50,6 @@ def must_not_call():
5050

5151
w3 = Web3(auto)
5252

53-
assert w3.isConnected()
53+
assert w3.is_connected()
5454

5555
assert isinstance(auto._active_provider, ConnectedProvider)

0 commit comments

Comments
 (0)