aboutsummaryrefslogtreecommitdiffstats
path: root/pathod/language/base.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-05-27 01:55:43 +0200
committerGitHub <noreply@github.com>2017-05-27 01:55:43 +0200
commite7f7a608c6dda7cc22d2eda1129da99fd2830767 (patch)
tree4c6879f8dc964010750617c47eb7ee927c891b6b /pathod/language/base.py
parentef1c36194e0cb3ac82304eb95fb323d71ec5ebab (diff)
parente7990e0983344179e49a46f160e1482a0a0f6aa7 (diff)
downloadmitmproxy-e7f7a608c6dda7cc22d2eda1129da99fd2830767.tar.gz
mitmproxy-e7f7a608c6dda7cc22d2eda1129da99fd2830767.tar.bz2
mitmproxy-e7f7a608c6dda7cc22d2eda1129da99fd2830767.zip
Merge pull request #2358 from mhils/make-mypy-great-again
Fix mypy annotations, update mypy
Diffstat (limited to 'pathod/language/base.py')
-rw-r--r--pathod/language/base.py45
1 files changed, 3 insertions, 42 deletions
diff --git a/pathod/language/base.py b/pathod/language/base.py
index c8892748..97871e7e 100644
--- a/pathod/language/base.py
+++ b/pathod/language/base.py
@@ -6,7 +6,8 @@ import pyparsing as pp
from mitmproxy.utils import strutils
from mitmproxy.utils import human
import typing # noqa
-from . import generators, exceptions
+from . import generators
+from . import exceptions
class Settings:
@@ -375,7 +376,7 @@ class OptionsOrValue(_Component):
class Integer(_Component):
- bounds = (None, None) # type: typing.Tuple[typing.Union[int, None], typing.Union[int , None]]
+ bounds = (None, None) # type: typing.Tuple[typing.Optional[int], typing.Optional[int]]
preamble = ""
def __init__(self, value):
@@ -537,43 +538,3 @@ class IntField(_Component):
def spec(self):
return "%s%s" % (self.preamble, self.origvalue)
-
-
-class NestedMessage(Token):
-
- """
- A nested message, as an escaped string with a preamble.
- """
- preamble = ""
- nest_type = None # type: ignore
-
- def __init__(self, value):
- Token.__init__(self)
- self.value = value
- try:
- self.parsed = self.nest_type(
- self.nest_type.expr().parseString(
- value.val.decode(),
- parseAll=True
- )
- )
- except pp.ParseException as v:
- raise exceptions.ParseException(v.msg, v.line, v.col)
-
- @classmethod
- def expr(cls):
- e = pp.Literal(cls.preamble).suppress()
- e = e + TokValueLiteral.expr()
- return e.setParseAction(lambda x: cls(*x))
-
- def values(self, settings):
- return [
- self.value.get_generator(settings),
- ]
-
- def spec(self):
- return "%s%s" % (self.preamble, self.value.spec())
-
- def freeze(self, settings):
- f = self.parsed.freeze(settings).spec()
- return self.__class__(TokValueLiteral(strutils.bytes_to_escaped_str(f.encode(), escape_single_quotes=True)))