Remove unreachable check in connection send_messages (#704)

This commit is contained in:
J. Nick Koston 2023-11-25 08:32:27 -06:00 committed by GitHub
parent b67e19bd94
commit 402d6fe113
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 11 deletions

View File

@ -41,6 +41,7 @@ cdef object HandshakeAPIError
cdef object PingFailedAPIError
cdef object ReadFailedAPIError
cdef object TimeoutAPIError
cdef object SocketAPIError
cdef object astuple

View File

@ -611,21 +611,16 @@ class APIConnection:
f"Connection isn't established yet ({self.connection_state})"
)
packets: list[tuple[int, bytes]] = []
debug_enabled = self._debug_enabled
packets: list[tuple[int, bytes]] = [
(PROTO_TO_MESSAGE_TYPE[type(msg)], msg.SerializeToString()) for msg in msgs
]
for msg in msgs:
msg_type = type(msg)
if (message_type := PROTO_TO_MESSAGE_TYPE.get(msg_type)) is None:
raise ValueError(f"Message type id not found for type {msg_type}")
if debug_enabled:
if debug_enabled := self._debug_enabled:
for msg in msgs:
_LOGGER.debug(
"%s: Sending %s: %s", self.log_name, msg_type.__name__, msg
"%s: Sending %s: %s", self.log_name, type(msg).__name__, msg
)
packets.append((message_type, msg.SerializeToString()))
if TYPE_CHECKING:
assert self._frame_helper is not None