Skip to content

Commit

Permalink
Enhance Type Hinting for WebSocket Connection (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
circansm committed Jun 11, 2024
1 parent 27a3468 commit 7f2f3cb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/solana/rpc/websocket_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,11 @@ def __init__(self, uri: str = "ws://localhost:8900", **kwargs: Any) -> None:
uri: The websocket endpoint.
**kwargs: Keyword arguments for ``websockets.legacy.client.connect``
"""
super().__init__(uri, **kwargs, create_protocol=SolanaWsClientProtocol)
# Ensure that create_protocol explicitly creates a SolanaWsClientProtocol
kwargs.setdefault("create_protocol", SolanaWsClientProtocol)
super().__init__(uri, **kwargs)

async def __aenter__(self) -> SolanaWsClientProtocol:
"""Overrides to specify the type of protocol explicitly."""
protocol = await super().__aenter__()
return cast(SolanaWsClientProtocol, protocol)

0 comments on commit 7f2f3cb

Please sign in to comment.