aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-12-14 15:28:14 +0100
committerMaximilian Hils <git@maximilianhils.com>2017-12-14 15:44:49 +0100
commitb9973bfbcfc10bb5fad6712a81510c231839e0a4 (patch)
treea9e04ae12fbf4960f851664b62b056551ca81eec
parent0af6e2e97f22137fe78e7e4dd56c0522ba72b54d (diff)
downloadmitmproxy-b9973bfbcfc10bb5fad6712a81510c231839e0a4.tar.gz
mitmproxy-b9973bfbcfc10bb5fad6712a81510c231839e0a4.tar.bz2
mitmproxy-b9973bfbcfc10bb5fad6712a81510c231839e0a4.zip
simplify path type
the previous implementation crashed the typechecker, as typing.NewType does not return a proper type that can be used for isinstance() checks.
-rw-r--r--mitmproxy/command.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/mitmproxy/command.py b/mitmproxy/command.py
index b8de6e36..c4821973 100644
--- a/mitmproxy/command.py
+++ b/mitmproxy/command.py
@@ -19,7 +19,8 @@ Cuts = typing.Sequence[
]
-Path = typing.NewType("Path", str)
+class Path(str):
+ pass
def typename(t: type, ret: bool) -> str:
@@ -37,10 +38,8 @@ def typename(t: type, ret: bool) -> str:
return "[cuts]" if ret else "cutspec"
elif t == flow.Flow:
return "flow"
- elif t == Path:
- return "path"
elif issubclass(t, (str, int, bool)):
- return t.__name__
+ return t.__name__.lower()
else: # pragma: no cover
raise NotImplementedError(t)
@@ -173,8 +172,6 @@ def parsearg(manager: CommandManager, spec: str, argtype: type) -> typing.Any:
"Invalid choice: see %s for options" % cmd
)
return spec
- if argtype == Path:
- return spec
elif issubclass(argtype, str):
return spec
elif argtype == bool: