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/http.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/http.py')
-rw-r--r-- | mitmproxy/http.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/mitmproxy/http.py b/mitmproxy/http.py index c6b17533..c09778fe 100644 --- a/mitmproxy/http.py +++ b/mitmproxy/http.py @@ -52,9 +52,7 @@ class HTTPRequest(http.Request): def get_state(self): state = super().get_state() - state.update( - is_replay=self.is_replay - ) + state["is_replay"] = self.is_replay return state def set_state(self, state): @@ -167,11 +165,12 @@ class HTTPFlow(flow.Flow): """ What mode was the proxy layer in when receiving this request? """ _stateobject_attributes = flow.Flow._stateobject_attributes.copy() - _stateobject_attributes.update( + # mypy doesn't support update with kwargs + _stateobject_attributes.update(dict( request=HTTPRequest, response=HTTPResponse, mode=str - ) + )) def __repr__(self): s = "<HTTPFlow" @@ -223,8 +222,7 @@ def make_error_response( status_code=status_code, reason=reason, message=html.escape(message), - ) - body = body.encode("utf8", "replace") + ).encode("utf8", "replace") if not headers: headers = http.Headers( |