From: Dmitry Selyutin Date: Wed, 28 Jun 2023 19:28:17 +0000 (+0300) Subject: dispatcher: determine function argument count via inspect X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=02ef49949991a739662a663ebe64ef00215c4e4d;p=mdis.git dispatcher: determine function argument count via inspect --- diff --git a/src/mdis/dispatcher.py b/src/mdis/dispatcher.py index 63b1ebb..8455039 100644 --- a/src/mdis/dispatcher.py +++ b/src/mdis/dispatcher.py @@ -34,9 +34,9 @@ class Hook(object): def __call__(self, call): class ConcreteHook(Hook): def __call__(self, dispatcher, node, *arguments): - try: + if (len(inspect.signature(call).parameters) > 2): return call(dispatcher, node, *arguments) - except TypeError: + else: return call(dispatcher, node) return ConcreteHook(*tuple(self))