dispatcher: determine function argument count via inspect
authorDmitry Selyutin <ghostmansd@gmail.com>
Wed, 28 Jun 2023 19:28:17 +0000 (22:28 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Wed, 28 Jun 2023 19:28:17 +0000 (22:28 +0300)
src/mdis/dispatcher.py

index 63b1ebb0888b53be59d4b16829fdc9e5715e48c7..8455039ce298d31637bd6b8c584bc3840c53b5ec 100644 (file)
@@ -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))