Skip to content

Commit 8193631

Browse files
cursoragentP4X-ng
andcommitted
Fix websockets typing for mypy compatibility
Co-authored-by: P4x-ng <P4X-ng@users.noreply.github.com>
1 parent ec86252 commit 8193631

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cdp/connection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@
1515

1616
try:
1717
import websockets
18-
from websockets.client import WebSocketClientProtocol
1918
WEBSOCKETS_AVAILABLE = True
2019
except ImportError:
2120
WEBSOCKETS_AVAILABLE = False
22-
WebSocketClientProtocol = typing.Any # type: ignore
21+
22+
if typing.TYPE_CHECKING:
23+
from websockets.legacy.client import WebSocketClientProtocol
24+
else:
25+
WebSocketClientProtocol = typing.Any
2326

2427
from cdp.util import parse_json_event, T_JSON_DICT
2528

0 commit comments

Comments
 (0)