aboutsummaryrefslogtreecommitdiffstats
path: root/pathod
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 /pathod
parent5eb17bbf6d47c8d703763bfa41cf1ff3f98a632f (diff)
downloadmitmproxy-0e984e1442e735a6a3cee5170bead492b231d620.tar.gz
mitmproxy-0e984e1442e735a6a3cee5170bead492b231d620.tar.bz2
mitmproxy-0e984e1442e735a6a3cee5170bead492b231d620.zip
fix Python 3.6 variable type annotations #3053
Diffstat (limited to 'pathod')
-rw-r--r--pathod/language/base.py8
-rw-r--r--pathod/language/message.py4
-rw-r--r--pathod/language/websockets.py6
-rw-r--r--pathod/pathod.py2
-rw-r--r--pathod/test.py2
-rw-r--r--pathod/utils.py2
6 files changed, 12 insertions, 12 deletions
diff --git a/pathod/language/base.py b/pathod/language/base.py
index 97871e7e..32cddca6 100644
--- a/pathod/language/base.py
+++ b/pathod/language/base.py
@@ -334,7 +334,7 @@ class OptionsOrValue(_Component):
Can be any of a specified set of options, or a value specifier.
"""
preamble = ""
- options = [] # type: typing.List[str]
+ options: typing.List[str] = []
def __init__(self, value):
# If it's a string, we were passed one of the options, so we lower-case
@@ -376,7 +376,7 @@ class OptionsOrValue(_Component):
class Integer(_Component):
- bounds = (None, None) # type: typing.Tuple[typing.Optional[int], typing.Optional[int]]
+ bounds: typing.Tuple[typing.Optional[int], typing.Optional[int]] = (None, None)
preamble = ""
def __init__(self, value):
@@ -442,7 +442,7 @@ class FixedLengthValue(Value):
A value component lead by an optional preamble.
"""
preamble = ""
- length = None # type: typing.Optional[int]
+ length: typing.Optional[int] = None
def __init__(self, value):
Value.__init__(self, value)
@@ -511,7 +511,7 @@ class IntField(_Component):
"""
An integer field, where values can optionally specified by name.
"""
- names = {} # type: typing.Dict[str, int]
+ names: typing.Dict[str, int] = {}
max = 16
preamble = ""
diff --git a/pathod/language/message.py b/pathod/language/message.py
index 5dda654b..566bce60 100644
--- a/pathod/language/message.py
+++ b/pathod/language/message.py
@@ -11,7 +11,7 @@ LOG_TRUNCATE = 1024
class Message:
__metaclass__ = abc.ABCMeta
- logattrs = [] # type: typing.List[str]
+ logattrs: typing.List[str] = []
def __init__(self, tokens):
track = set([])
@@ -106,7 +106,7 @@ class NestedMessage(base.Token):
A nested message, as an escaped string with a preamble.
"""
preamble = ""
- nest_type = None # type: typing.Optional[typing.Type[Message]]
+ nest_type: typing.Optional[typing.Type[Message]] = None
def __init__(self, value):
super().__init__()
diff --git a/pathod/language/websockets.py b/pathod/language/websockets.py
index cc00bcf1..34b4a307 100644
--- a/pathod/language/websockets.py
+++ b/pathod/language/websockets.py
@@ -16,14 +16,14 @@ class WF(base.CaselessLiteral):
class OpCode(base.IntField):
- names = {
+ names: typing.Dict[str, int] = {
"continue": mitmproxy.net.websockets.OPCODE.CONTINUE,
"text": mitmproxy.net.websockets.OPCODE.TEXT,
"binary": mitmproxy.net.websockets.OPCODE.BINARY,
"close": mitmproxy.net.websockets.OPCODE.CLOSE,
"ping": mitmproxy.net.websockets.OPCODE.PING,
"pong": mitmproxy.net.websockets.OPCODE.PONG,
- } # type: typing.Dict[str, int]
+ }
max = 15
preamble = "c"
@@ -97,7 +97,7 @@ COMPONENTS = [
class WebsocketFrame(message.Message):
- components = COMPONENTS # type: typing.List[typing.Type[base._Component]]
+ components: typing.List[typing.Type[base._Component]] = COMPONENTS
logattrs = ["body"]
# Used for nested frames
unique_name = "body"
diff --git a/pathod/pathod.py b/pathod/pathod.py
index 17db57ee..b330a293 100644
--- a/pathod/pathod.py
+++ b/pathod/pathod.py
@@ -69,7 +69,7 @@ class SSLOptions:
class PathodHandler(tcp.BaseHandler):
wbufsize = 0
- sni = None # type: typing.Union[str, None, bool]
+ sni: typing.Union[str, None, bool] = None
def __init__(
self,
diff --git a/pathod/test.py b/pathod/test.py
index 819c7a94..e8c3c84a 100644
--- a/pathod/test.py
+++ b/pathod/test.py
@@ -10,7 +10,7 @@ class Daemon:
IFACE = "127.0.0.1"
def __init__(self, ssl=None, **daemonargs) -> None:
- self.q = queue.Queue() # type: queue.Queue
+ self.q: queue.Queue = queue.Queue()
self.logfp = io.StringIO()
daemonargs["logfp"] = self.logfp
self.thread = _PaThread(self.IFACE, self.q, ssl, daemonargs)
diff --git a/pathod/utils.py b/pathod/utils.py
index 11b1dccd..4ef85439 100644
--- a/pathod/utils.py
+++ b/pathod/utils.py
@@ -11,7 +11,7 @@ class MemBool:
"""
def __init__(self) -> None:
- self.v = None # type: typing.Optional[bool]
+ self.v: typing.Optional[bool] = None
def __call__(self, v: bool) -> bool:
self.v = v