aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mitmproxy/command.py5
-rw-r--r--test/mitmproxy/test_command.py13
2 files changed, 17 insertions, 1 deletions
diff --git a/mitmproxy/command.py b/mitmproxy/command.py
index 8f075525..cba2673c 100644
--- a/mitmproxy/command.py
+++ b/mitmproxy/command.py
@@ -58,7 +58,10 @@ class Command:
if i.kind == i.VAR_POSITIONAL:
self.has_positional = True
self.paramtypes = [v.annotation for v in sig.parameters.values()]
- self.returntype = sig.return_annotation
+ if sig.return_annotation == inspect._empty:
+ self.returntype = None
+ else:
+ self.returntype = sig.return_annotation
def paramnames(self) -> typing.Sequence[str]:
v = [typename(i) for i in self.paramtypes]
diff --git a/test/mitmproxy/test_command.py b/test/mitmproxy/test_command.py
index ea1017e7..22ebcc21 100644
--- a/test/mitmproxy/test_command.py
+++ b/test/mitmproxy/test_command.py
@@ -55,7 +55,20 @@ class TAddon:
pass
+class TypeErrAddon:
+ @command.command("noret")
+ def noret(self):
+ pass
+
+
class TestCommand:
+ def test_typecheck(self):
+ with taddons.context(loadcore=False) as tctx:
+ cm = command.CommandManager(tctx.master)
+ a = TypeErrAddon()
+ c = command.Command(cm, "noret", a.noret)
+ print(c.signature_help())
+
def test_varargs(self):
with taddons.context() as tctx:
cm = command.CommandManager(tctx.master)