diff options
author | Maximilian Hils <git@maximilianhils.com> | 2017-07-20 16:27:13 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2017-07-20 16:27:13 +0200 |
commit | 7b0485d6d6d1f3cc5d6704db39971b69dc030b80 (patch) | |
tree | ede5360d465f6b06b7fb4f616fa832758c74acca /mitmproxy/eventsequence.py | |
parent | 9176626dab56f9437324b56ac0b2751834dc3ead (diff) | |
download | mitmproxy-7b0485d6d6d1f3cc5d6704db39971b69dc030b80.tar.gz mitmproxy-7b0485d6d6d1f3cc5d6704db39971b69dc030b80.tar.bz2 mitmproxy-7b0485d6d6d1f3cc5d6704db39971b69dc030b80.zip |
update mypy
Diffstat (limited to 'mitmproxy/eventsequence.py')
-rw-r--r-- | mitmproxy/eventsequence.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/mitmproxy/eventsequence.py b/mitmproxy/eventsequence.py index 68d97a23..d263727b 100644 --- a/mitmproxy/eventsequence.py +++ b/mitmproxy/eventsequence.py @@ -1,8 +1,8 @@ import typing from mitmproxy import controller -from mitmproxy import http from mitmproxy import flow +from mitmproxy import http from mitmproxy import tcp from mitmproxy import websocket @@ -40,8 +40,10 @@ Events = frozenset([ "update", ]) +TEventGenerator = typing.Iterator[typing.Tuple[str, typing.Any]] + -def _iterate_http(f: http.HTTPFlow): +def _iterate_http(f: http.HTTPFlow) -> TEventGenerator: if f.request: yield "requestheaders", f yield "request", f @@ -52,7 +54,7 @@ def _iterate_http(f: http.HTTPFlow): yield "error", f -def _iterate_websocket(f: websocket.WebSocketFlow): +def _iterate_websocket(f: websocket.WebSocketFlow) -> TEventGenerator: messages = f.messages f.messages = [] f.reply = controller.DummyReply() @@ -65,7 +67,7 @@ def _iterate_websocket(f: websocket.WebSocketFlow): yield "websocket_end", f -def _iterate_tcp(f: tcp.TCPFlow): +def _iterate_tcp(f: tcp.TCPFlow) -> TEventGenerator: messages = f.messages f.messages = [] f.reply = controller.DummyReply() @@ -78,19 +80,17 @@ def _iterate_tcp(f: tcp.TCPFlow): yield "tcp_end", f -TEventGenerator = typing.Iterator[typing.Tuple[str, typing.Any]] - _iterate_map = { http.HTTPFlow: _iterate_http, websocket.WebSocketFlow: _iterate_websocket, - tcp.TCPFlow: _iterate_tcp -} # type: typing.Dict[typing.Type[flow.Flow], typing.Callable[[flow.Flow], TEventGenerator]] + tcp.TCPFlow: _iterate_tcp, +} # type: typing.Dict[typing.Type[flow.Flow], typing.Callable[[typing.Any], TEventGenerator]] def iterate(f: flow.Flow) -> TEventGenerator: try: e = _iterate_map[type(f)] - except KeyError as e: - raise TypeError("Unknown flow type: {}".format(f)) from e + except KeyError as err: + raise TypeError("Unknown flow type: {}".format(f)) from err else: yield from e(f) |