Prepare websocket writer for aiohttp 3.11 (#127043)

This commit is contained in:
J. Nick Koston 2024-10-03 15:29:29 -05:00 committed by GitHub
parent 10c033e580
commit c3f0f30910
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -328,7 +328,13 @@ class WebSocketHandler:
if TYPE_CHECKING:
assert writer is not None
send_bytes_text = partial(writer.send, binary=False)
# aiohttp 3.11.0 changed the method name from _send_frame to send_frame
if hasattr(writer, "send_frame"):
send_frame = writer.send_frame # pragma: no cover
else:
send_frame = writer._send_frame # noqa: SLF001
send_bytes_text = partial(send_frame, opcode=WSMsgType.TEXT)
auth = AuthPhase(
logger, hass, self._send_message, self._cancel, request, send_bytes_text
)