Skip to content

Commit 2c431f6

Browse files
committed
snakecase isConnected
1 parent 7f372c4 commit 2c431f6

File tree

17 files changed

+39
-39
lines changed

17 files changed

+39
-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

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)

tests/core/utilities/test_attach_modules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def test_attach_external_modules_multiple_levels_deep(
127127
},
128128
)
129129

130-
assert w3.isConnected()
130+
assert w3.is_connected()
131131

132132
# assert instantiated with default modules
133133
assert hasattr(w3, "geth")

web3/_utils/module_testing/eth_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ async def test_eth_gas_price(self, async_w3: "Web3") -> None:
110110
assert gas_price > 0
111111

112112
@pytest.mark.asyncio
113-
async def test_isConnected(self, async_w3: "Web3") -> None:
114-
is_connected = await async_w3.isConnected() # type: ignore
113+
async def test_is_connected(self, async_w3: "Web3") -> None:
114+
is_connected = await async_w3.is_connected() # type: ignore
115115
assert is_connected is True
116116

117117
@pytest.mark.asyncio

web3/_utils/module_testing/web3_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,4 @@ def test_solidityKeccak_same_number_of_types_and_values(
294294
w3.solidityKeccak(types, values)
295295

296296
def test_is_connected(self, w3: "Web3") -> None:
297-
assert w3.isConnected()
297+
assert w3.is_connected()

web3/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ def attach_modules(
338338
"""
339339
_attach_modules(self, modules)
340340

341-
def isConnected(self) -> Union[bool, Coroutine[Any, Any, bool]]:
342-
return self.provider.isConnected()
341+
def is_connected(self) -> Union[bool, Coroutine[Any, Any, bool]]:
342+
return self.provider.is_connected()
343343

344344
def is_encodable(self, _type: TypeStr, value: Any) -> bool:
345345
return self.codec.is_encodable(_type, value)

web3/providers/async_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async def _generate_request_func(
8282
async def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse:
8383
raise NotImplementedError("Providers must implement this method")
8484

85-
async def isConnected(self) -> bool:
85+
async def is_connected(self) -> bool:
8686
raise NotImplementedError("Providers must implement this method")
8787

8888

@@ -104,7 +104,7 @@ def decode_rpc_response(self, raw_response: bytes) -> RPCResponse:
104104
text_response = to_text(raw_response)
105105
return cast(RPCResponse, FriendlyJsonSerde().json_decode(text_response))
106106

107-
async def isConnected(self) -> bool:
107+
async def is_connected(self) -> bool:
108108
try:
109109
response = await self.make_request(RPCEndpoint("web3_clientVersion"), [])
110110
except OSError:

web3/providers/auto.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse:
9595
except OSError:
9696
return self._proxy_request(method, params, use_cache=False)
9797

98-
def isConnected(self) -> bool:
98+
def is_connected(self) -> bool:
9999
provider = self._get_active_provider(use_cache=True)
100-
return provider is not None and provider.isConnected()
100+
return provider is not None and provider.is_connected()
101101

102102
def _proxy_request(
103103
self, method: RPCEndpoint, params: Any, use_cache: bool = True
@@ -117,7 +117,7 @@ def _get_active_provider(self, use_cache: bool) -> Optional[BaseProvider]:
117117

118118
for Provider in self._potential_providers:
119119
provider = Provider()
120-
if provider is not None and provider.isConnected():
120+
if provider is not None and provider.is_connected():
121121
self._active_provider = provider
122122
return provider
123123

web3/providers/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def _generate_request_func(
8282
def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse:
8383
raise NotImplementedError("Providers must implement this method")
8484

85-
def isConnected(self) -> bool:
85+
def is_connected(self) -> bool:
8686
raise NotImplementedError("Providers must implement this method")
8787

8888

@@ -104,7 +104,7 @@ def encode_rpc_request(self, method: RPCEndpoint, params: Any) -> bytes:
104104
encoded = FriendlyJsonSerde().json_encode(rpc_dict)
105105
return to_bytes(text=encoded)
106106

107-
def isConnected(self) -> bool:
107+
def is_connected(self) -> bool:
108108
try:
109109
response = self.make_request(RPCEndpoint("web3_clientVersion"), [])
110110
except OSError:

web3/providers/eth_tester/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ async def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse:
8585
"result": response,
8686
}
8787

88-
async def isConnected(self) -> Literal[True]:
88+
async def is_connected(self) -> Literal[True]:
8989
return True
9090

9191

@@ -157,5 +157,5 @@ def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse:
157157
"result": response,
158158
}
159159

160-
def isConnected(self) -> Literal[True]:
160+
def is_connected(self) -> Literal[True]:
161161
return True

0 commit comments

Comments
 (0)