aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authoroscure76 <midhun.nitw@gmail.com>2018-04-14 16:24:41 -0700
committeroscure76 <midhun.nitw@gmail.com>2018-04-14 16:24:41 -0700
commit0e984e1442e735a6a3cee5170bead492b231d620 (patch)
tree4e0ae4b5598f3c1be35a38819b15a12ace6209c8 /examples
parent5eb17bbf6d47c8d703763bfa41cf1ff3f98a632f (diff)
downloadmitmproxy-0e984e1442e735a6a3cee5170bead492b231d620.tar.gz
mitmproxy-0e984e1442e735a6a3cee5170bead492b231d620.tar.bz2
mitmproxy-0e984e1442e735a6a3cee5170bead492b231d620.zip
fix Python 3.6 variable type annotations #3053
Diffstat (limited to 'examples')
-rw-r--r--examples/complex/har_dump.py8
-rw-r--r--examples/complex/sslstrip.py2
-rwxr-xr-xexamples/complex/xss_scanner.py4
-rw-r--r--examples/simple/filter_flows.py2
-rw-r--r--examples/simple/io_write_dumpfile.py2
5 files changed, 9 insertions, 9 deletions
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: