Skip to content

Commit 645085d

Browse files
committed
Pr review updates
1 parent be7acaf commit 645085d

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

web3/providers/ipc.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from json import (
2+
JSONDecodeError,
3+
)
14
import logging
25
import os
36
from pathlib import (
@@ -6,6 +9,9 @@
69
import socket
710
import sys
811
import threading
12+
from types import (
13+
TracebackType,
14+
)
915
from typing import (
1016
Any,
1117
Type,
@@ -23,13 +29,6 @@
2329
JSONBaseProvider,
2430
)
2531

26-
try:
27-
from json import JSONDecodeError
28-
except ImportError:
29-
# type ignored b/c mypy unhappy w/ conflicting exception types
30-
# difficult to cast / resolve w/ conditional import
31-
JSONDecodeError = ValueError # type: ignore
32-
3332

3433
def get_ipc_socket(ipc_path: str, timeout: float=0.1) -> socket.socket:
3534
if sys.platform == 'win32':
@@ -58,7 +57,9 @@ def __enter__(self) -> socket.socket:
5857
self.sock = self._open()
5958
return self.sock
6059

61-
def __exit__(self, exc_type: Type[BaseException], exc_value: Any, traceback: Any) -> None:
60+
def __exit__(
61+
self, exc_type: Type[BaseException], exc_value: BaseException, traceback: TracebackType
62+
) -> None:
6263
# only close the socket if there was an error
6364
if exc_value is not None:
6465
try:

web3/providers/rpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __str__(self) -> str:
6161
return "RPC connection {0}".format(self.endpoint_uri)
6262

6363
@to_dict
64-
def get_request_kwargs(self) -> Iterable[Tuple[Any, Any]]:
64+
def get_request_kwargs(self) -> Iterable[Tuple[str, Any]]:
6565
if 'headers' not in self._request_kwargs:
6666
yield 'headers', self.get_request_headers()
6767
for key, value in self._request_kwargs.items():

web3/providers/websocket.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
from threading import (
66
Thread,
77
)
8+
from types import (
9+
TracebackType,
10+
)
811
from typing import (
912
Any,
1013
Type,
@@ -64,7 +67,9 @@ async def __aenter__(self) -> websockets.WebSocketClientProtocol:
6467
)
6568
return self.ws
6669

67-
async def __aexit__(self, exc_type: Type[BaseException], exc_val: Any, exc_tb: Any) -> None:
70+
async def __aexit__(
71+
self, exc_type: Type[BaseException], exc_val: BaseException, exc_tb: TracebackType
72+
) -> None:
6873
if exc_val is not None:
6974
try:
7075
await self.ws.close()

0 commit comments

Comments
 (0)