From b9973bfbcfc10bb5fad6712a81510c231839e0a4 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 14 Dec 2017 15:28:14 +0100 Subject: 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. --- mitmproxy/command.py | 9 +++------ 1 file 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: -- cgit v1.2.3