From 0e984e1442e735a6a3cee5170bead492b231d620 Mon Sep 17 00:00:00 2001 From: oscure76 Date: Sat, 14 Apr 2018 16:24:41 -0700 Subject: fix Python 3.6 variable type annotations #3053 --- examples/complex/har_dump.py | 8 ++++---- examples/complex/sslstrip.py | 2 +- examples/complex/xss_scanner.py | 4 ++-- examples/simple/filter_flows.py | 2 +- examples/simple/io_write_dumpfile.py | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'examples') diff --git a/examples/complex/har_dump.py b/examples/complex/har_dump.py index 9e287a19..040c7d28 100644 --- a/examples/complex/har_dump.py +++ b/examples/complex/har_dump.py @@ -20,11 +20,11 @@ from mitmproxy import ctx from mitmproxy.utils import strutils from mitmproxy.net.http import cookies -HAR = {} # type: typing.Dict +HAR: typing.Dict = {} # A list of server seen till now is maintained so we can avoid # using 'connect' time for entries that use an existing connection. -SERVERS_SEEN = set() # type: typing.Set[connections.ServerConnection] +SERVERS_SEEN: typing.Set[connections.ServerConnection] = set() def load(l): @@ -155,12 +155,12 @@ def done(): Called once on script shutdown, after any other events. """ if ctx.options.hardump: - json_dump = json.dumps(HAR, indent=2) # type: str + json_dump: str = json.dumps(HAR, indent=2) if ctx.options.hardump == '-': mitmproxy.ctx.log(json_dump) else: - raw = json_dump.encode() # type: bytes + raw: bytes = json_dump.encode() if ctx.options.hardump.endswith('.zhar'): raw = zlib.compress(raw, 9) diff --git a/examples/complex/sslstrip.py b/examples/complex/sslstrip.py index c3f8c4f7..c862536f 100644 --- a/examples/complex/sslstrip.py +++ b/examples/complex/sslstrip.py @@ -9,7 +9,7 @@ import typing # noqa from mitmproxy import http # set of SSL/TLS capable hosts -secure_hosts = set() # type: typing.Set[str] +secure_hosts: typing.Set[str] = set() def request(flow: http.HTTPFlow) -> None: diff --git a/examples/complex/xss_scanner.py b/examples/complex/xss_scanner.py index 0c0dd0f3..55fc2fe7 100755 --- a/examples/complex/xss_scanner.py +++ b/examples/complex/xss_scanner.py @@ -95,7 +95,7 @@ def find_unclaimed_URLs(body: str, requestUrl: bytes) -> None: return None class ScriptURLExtractor(HTMLParser): - script_URLs = [] # type: List[str] + script_URLs: List[str] = [] def handle_starttag(self, tag, attrs): if (tag == "script" or tag == "iframe") and "src" in [name for name, value in attrs]: @@ -254,7 +254,7 @@ def paths_to_text(html: str, string: str) -> List[str]: class PathHTMLParser(HTMLParser): currentPath = "" - paths = [] # type: List[str] + paths: List[str] = [] def handle_starttag(self, tag, attrs): self.currentPath += ("/" + tag) diff --git a/examples/simple/filter_flows.py b/examples/simple/filter_flows.py index 70979591..d252089c 100644 --- a/examples/simple/filter_flows.py +++ b/examples/simple/filter_flows.py @@ -7,7 +7,7 @@ from mitmproxy import ctx, http class Filter: def __init__(self): - self.filter = None # type: flowfilter.TFilter + self.filter: flowfilter.TFilter = None def configure(self, updated): self.filter = flowfilter.parse(ctx.options.flowfilter) diff --git a/examples/simple/io_write_dumpfile.py b/examples/simple/io_write_dumpfile.py index be6e4121..c8c59c62 100644 --- a/examples/simple/io_write_dumpfile.py +++ b/examples/simple/io_write_dumpfile.py @@ -13,7 +13,7 @@ import typing # noqa class Writer: def __init__(self, path: str) -> None: - self.f = open(path, "wb") # type: typing.IO[bytes] + self.f: typing.IO[bytes] = open(path, "wb") self.w = io.FlowWriter(self.f) def response(self, flow: http.HTTPFlow) -> None: -- cgit v1.2.3