From 2bb5f7b973285dc014d3a1fbf0b072676cd8ed6c Mon Sep 17 00:00:00 2001 From: Alexander Prinzhorn Date: Fri, 7 Aug 2020 12:03:13 +0200 Subject: [PATCH] Updated typing for WebsocketMessage.content --- CHANGELOG | 1 + mitmproxy/websocket.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ecf739486..85891f243 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ Unreleased: mitmproxy next * Add MsgPack content viewer (@tasn) * Fix links to anticache docs in mitmweb and use HTTPS for links to documentation (@rugk) + * Updated typing for WebsocketMessage.content (@prinzhorn) * --- TODO: add new PRs above this line --- diff --git a/mitmproxy/websocket.py b/mitmproxy/websocket.py index 3468ec0e2..9ab26deab 100644 --- a/mitmproxy/websocket.py +++ b/mitmproxy/websocket.py @@ -1,6 +1,6 @@ import time import queue -from typing import List, Optional +from typing import List, Optional, Union from wsproto.frame_protocol import CloseReason from wsproto.frame_protocol import Opcode @@ -17,7 +17,7 @@ class WebSocketMessage(serializable.Serializable): """ def __init__( - self, type: int, from_client: bool, content: bytes, timestamp: Optional[float]=None, killed: bool=False + self, type: int, from_client: bool, content: Union[bytes, str], timestamp: Optional[float]=None, killed: bool=False ) -> None: self.type = Opcode(type) # type: ignore """indicates either TEXT or BINARY (from wsproto.frame_protocol.Opcode)."""