diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2017-03-16 16:50:41 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@corte.si> | 2017-03-17 08:13:47 +1300 |
commit | 5192810ff6a41e62e41d16fcf636663d177a1232 (patch) | |
tree | c3fc61680fb63af27df357a198584610772a47b0 /mitmproxy/websocket.py | |
parent | eac210829e51d988b7090b448037de6d41d5dfe9 (diff) | |
download | mitmproxy-5192810ff6a41e62e41d16fcf636663d177a1232.tar.gz mitmproxy-5192810ff6a41e62e41d16fcf636663d177a1232.tar.bz2 mitmproxy-5192810ff6a41e62e41d16fcf636663d177a1232.zip |
Make mypy succeed with imports on master.py
We get little benefit from our mypy QA checks at the moment, because we skip
imports. This patch is what's needed to make mypy succeed with imports on a
single file: master.py
It also updates mypy to the current version, and enables a QA check.
Mypy bugs I encountered:
dict.update with kwargs not supported:
https://github.com/python/mypy/issues/1031
property setters and getters must be adjacent:
https://github.com/python/mypy/issues/1465
Diffstat (limited to 'mitmproxy/websocket.py')
-rw-r--r-- | mitmproxy/websocket.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/mitmproxy/websocket.py b/mitmproxy/websocket.py index 5d76aafc..2efa7ad1 100644 --- a/mitmproxy/websocket.py +++ b/mitmproxy/websocket.py @@ -8,11 +8,13 @@ from mitmproxy.utils import strutils class WebSocketMessage(serializable.Serializable): - def __init__(self, type: int, from_client: bool, content: bytes, timestamp: Optional[int]=None): + def __init__( + self, type: int, from_client: bool, content: bytes, timestamp: Optional[int]=None + ) -> None: self.type = type self.from_client = from_client self.content = content - self.timestamp = timestamp or time.time() # type: int + self.timestamp = timestamp or int(time.time()) # type: int @classmethod def from_state(cls, state): @@ -62,7 +64,8 @@ class WebSocketFlow(flow.Flow): self.handshake_flow = handshake_flow _stateobject_attributes = flow.Flow._stateobject_attributes.copy() - _stateobject_attributes.update( + # mypy doesn't support update with kwargs + _stateobject_attributes.update(dict( messages=List[WebSocketMessage], close_sender=str, close_code=str, @@ -77,7 +80,7 @@ class WebSocketFlow(flow.Flow): # Do not include handshake_flow, to prevent recursive serialization! # Since mitmproxy-console currently only displays HTTPFlows, # dumping the handshake_flow will include the WebSocketFlow too. - ) + )) @classmethod def from_state(cls, state): |