diff --git a/uvicorn/protocols/websockets/wsproto_impl.py b/uvicorn/protocols/websockets/wsproto_impl.py index 40c96fd18..d682eb9f9 100644 --- a/uvicorn/protocols/websockets/wsproto_impl.py +++ b/uvicorn/protocols/websockets/wsproto_impl.py @@ -15,7 +15,6 @@ WebSocketAcceptEvent, WebSocketCloseEvent, WebSocketEvent, - WebSocketReceiveEvent, WebSocketScope, WebSocketSendEvent, ) @@ -181,11 +180,7 @@ def handle_connect(self, event: events.Request) -> None: def handle_text(self, event: events.TextMessage) -> None: self.text += event.data if event.message_finished: - msg: "WebSocketReceiveEvent" = { - "type": "websocket.receive", - "text": self.text, - } - self.queue.put_nowait(msg) + self.queue.put_nowait({"type": "websocket.receive", "text": self.text}) self.text = "" if not self.read_paused: self.read_paused = True @@ -195,11 +190,7 @@ def handle_bytes(self, event: events.BytesMessage) -> None: self.bytes += event.data # todo: we may want to guard the size of self.bytes and self.text if event.message_finished: - msg: WebSocketReceiveEvent = { - "type": "websocket.receive", - "bytes": self.bytes, - } - self.queue.put_nowait(msg) + self.queue.put_nowait({"type": "websocket.receive", "bytes": self.bytes}) self.bytes = b"" if not self.read_paused: self.read_paused = True