diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2017-04-27 15:27:51 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2017-04-27 15:27:51 +1200 |
commit | 8c4810f6069bcf592d480e5cc2d7338cd176085e (patch) | |
tree | f3e76c6b5af13e57e84cce28c2acc35a9018aad4 /mitmproxy/utils | |
parent | ee3dd3f3c5b6fe42df547156f25ab6e6f6578fff (diff) | |
download | mitmproxy-8c4810f6069bcf592d480e5cc2d7338cd176085e.tar.gz mitmproxy-8c4810f6069bcf592d480e5cc2d7338cd176085e.tar.bz2 mitmproxy-8c4810f6069bcf592d480e5cc2d7338cd176085e.zip |
console: flow resolution command
This is our first built-in command, which will be used by very many other
commands.
Also add a --commands option to dump all commands, analogous to --options.
Diffstat (limited to 'mitmproxy/utils')
-rw-r--r-- | mitmproxy/utils/typecheck.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/mitmproxy/utils/typecheck.py b/mitmproxy/utils/typecheck.py index 7199f2fb..33dd70b0 100644 --- a/mitmproxy/utils/typecheck.py +++ b/mitmproxy/utils/typecheck.py @@ -7,6 +7,20 @@ def check_command_return_type(value: typing.Any, typeinfo: typing.Any) -> bool: types match, False otherwise. This function supports only those types required for command return values. """ + typename = str(typeinfo) + if typename.startswith("typing.Sequence"): + try: + T = typeinfo.__args__[0] # type: ignore + except AttributeError: + # Python 3.5.0 + T = typeinfo.__parameters__[0] # type: ignore + if not isinstance(value, (tuple, list)): + return False + for v in value: + if not check_command_return_type(v, T): + return False + elif not isinstance(value, typeinfo): + return False return True |