aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/utils
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2017-12-13 10:45:31 +1300
committerAldo Cortesi <aldo@corte.si>2017-12-13 11:08:14 +1300
commit4cee1a4f96ef7307e422cf227c8389563323e442 (patch)
tree9e3febc8771eccf2eb6a228e037715b60ae651a7 /mitmproxy/utils
parent91a297969494aad68eb46163c004734223a4abd1 (diff)
downloadmitmproxy-4cee1a4f96ef7307e422cf227c8389563323e442.tar.gz
mitmproxy-4cee1a4f96ef7307e422cf227c8389563323e442.tar.bz2
mitmproxy-4cee1a4f96ef7307e422cf227c8389563323e442.zip
commands: formalise a Choice type
This resolves as a string during MyPy checks, but at runtime has an additional attribute that is a command that returns valid options. This is very ugly and clumsy, basically because MyPy is super restrictive about what it accepts as a type. Almost any attempt to construct these types in a more sophisticated way fails in one way or another. I'm open to suggestions.
Diffstat (limited to 'mitmproxy/utils')
-rw-r--r--mitmproxy/utils/typecheck.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/mitmproxy/utils/typecheck.py b/mitmproxy/utils/typecheck.py
index 87a0e804..c5e289a4 100644
--- a/mitmproxy/utils/typecheck.py
+++ b/mitmproxy/utils/typecheck.py
@@ -31,7 +31,7 @@ def check_command_type(value: typing.Any, typeinfo: typing.Any) -> bool:
return False
elif value is None and typeinfo is None:
return True
- elif not isinstance(value, typeinfo):
+ elif (not isinstance(typeinfo, type)) or (not isinstance(value, typeinfo)):
return False
return True