diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2017-04-30 21:20:32 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2017-04-30 21:24:00 +1200 |
commit | 3cd93567f5be263f1b40b2545573d024f69d2bdd (patch) | |
tree | b2d8ab7aec197a56db69ef4e82d1451fd0d7063d /mitmproxy/utils | |
parent | bcbe87bb0986819c83c3e2efc683194bbf9c6c50 (diff) | |
download | mitmproxy-3cd93567f5be263f1b40b2545573d024f69d2bdd.tar.gz mitmproxy-3cd93567f5be263f1b40b2545573d024f69d2bdd.tar.bz2 mitmproxy-3cd93567f5be263f1b40b2545573d024f69d2bdd.zip |
commands: support *args for commands
Use this to simplify meta-commands in console, and to create a console_choose
command that prompts the user for a choice, and then executes a command with
variable substitution.
Diffstat (limited to 'mitmproxy/utils')
-rw-r--r-- | mitmproxy/utils/typecheck.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/mitmproxy/utils/typecheck.py b/mitmproxy/utils/typecheck.py index c97ff529..a5f27fee 100644 --- a/mitmproxy/utils/typecheck.py +++ b/mitmproxy/utils/typecheck.py @@ -1,7 +1,7 @@ import typing -def check_command_return_type(value: typing.Any, typeinfo: typing.Any) -> bool: +def check_command_type(value: typing.Any, typeinfo: typing.Any) -> bool: """ Check if the provided value is an instance of typeinfo. Returns True if the types match, False otherwise. This function supports only those types @@ -17,7 +17,7 @@ def check_command_return_type(value: typing.Any, typeinfo: typing.Any) -> bool: if not isinstance(value, (tuple, list)): return False for v in value: - if not check_command_return_type(v, T): + if not check_command_type(v, T): return False elif typename.startswith("typing.Union"): try: @@ -26,7 +26,7 @@ def check_command_return_type(value: typing.Any, typeinfo: typing.Any) -> bool: # Python 3.5.x types = typeinfo.__union_params__ # type: ignore for T in types: - checks = [check_command_return_type(value, T) for T in types] + checks = [check_command_type(value, T) for T in types] if not any(checks): return False elif value is None and typeinfo is None: |