Skip to content

Commit 650d08c

Browse files
committed
Upgrade to mypy 1.11.
1 parent f45286b commit 650d08c

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/websockets/legacy/auth.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ async def check_credentials(username: str, password: str) -> bool:
178178
if create_protocol is None:
179179
create_protocol = BasicAuthWebSocketServerProtocol
180180

181+
# Help mypy and avoid this error: "type[BasicAuthWebSocketServerProtocol] |
182+
# Callable[..., BasicAuthWebSocketServerProtocol]" not callable [misc]
183+
create_protocol = cast(
184+
Callable[..., BasicAuthWebSocketServerProtocol], create_protocol
185+
)
181186
return functools.partial(
182187
create_protocol,
183188
realm=realm,

src/websockets/legacy/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,9 @@ def __init__(
489489
if subprotocols is not None:
490490
validate_subprotocols(subprotocols)
491491

492+
# Help mypy and avoid this error: "type[WebSocketClientProtocol] |
493+
# Callable[..., WebSocketClientProtocol]" not callable [misc]
494+
create_protocol = cast(Callable[..., WebSocketClientProtocol], create_protocol)
492495
factory = functools.partial(
493496
create_protocol,
494497
logger=logger,
@@ -641,8 +644,7 @@ def __await__(self) -> Generator[Any, None, WebSocketClientProtocol]:
641644
async def __await_impl__(self) -> WebSocketClientProtocol:
642645
async with asyncio_timeout(self.open_timeout):
643646
for _redirects in range(self.MAX_REDIRECTS_ALLOWED):
644-
_transport, _protocol = await self._create_connection()
645-
protocol = cast(WebSocketClientProtocol, _protocol)
647+
_transport, protocol = await self._create_connection()
646648
try:
647649
await protocol.handshake(
648650
self._wsuri,

src/websockets/legacy/server.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,9 @@ def __init__(
10451045
if subprotocols is not None:
10461046
validate_subprotocols(subprotocols)
10471047

1048+
# Help mypy and avoid this error: "type[WebSocketServerProtocol] |
1049+
# Callable[..., WebSocketServerProtocol]" not callable [misc]
1050+
create_protocol = cast(Callable[..., WebSocketServerProtocol], create_protocol)
10481051
factory = functools.partial(
10491052
create_protocol,
10501053
# For backwards compatibility with 10.0 or earlier. Done here in

0 commit comments

Comments
 (0)