diff --git a/mitmproxy/contentviews.py b/mitmproxy/contentviews.py index 054f1f2d2..e155bc01e 100644 --- a/mitmproxy/contentviews.py +++ b/mitmproxy/contentviews.py @@ -109,12 +109,16 @@ class View(object): prompt = () content_types = [] - def __call__(self, data, **metadata): + def __call__( + self, + data, # type: bytes + **metadata + ): """ Transform raw data into human-readable output. Args: - data: the data to decode/format as bytes. + data: the data to decode/format. metadata: optional keyword-only arguments for metadata. Implementations must not rely on a given argument being present. @@ -282,7 +286,7 @@ class ViewURLEncoded(View): def __call__(self, data, **metadata): try: - data = data.decode("ascii","strict") + data = data.decode("ascii", "strict") except ValueError: return None d = url.decode(data) diff --git a/netlib/http/url.py b/netlib/http/url.py index 2fc6e7eed..1c8c007a7 100644 --- a/netlib/http/url.py +++ b/netlib/http/url.py @@ -82,6 +82,7 @@ def unparse(scheme, host, port, path=""): def encode(s): + # type: (six.text_type, bytes) -> str """ Takes a list of (key, value) tuples and returns a urlencoded string. """ diff --git a/test/mitmproxy/test_contentview.py b/test/mitmproxy/test_contentview.py index 2db9ab40a..aad53b372 100644 --- a/test/mitmproxy/test_contentview.py +++ b/test/mitmproxy/test_contentview.py @@ -59,10 +59,10 @@ class TestContentView: assert f[0] == "Query" def test_view_urlencoded(self): - d = url.encode([("one", "two"), ("three", "four")]) + d = url.encode([("one", "two"), ("three", "four")]).encode() v = cv.ViewURLEncoded() assert v(d) - d = url.encode([("adsfa", "")]) + d = url.encode([("adsfa", "")]).encode() v = cv.ViewURLEncoded() assert v(d)