From 27d4a204187f01d088239b0ce7adb727e92b33a1 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 17 May 2023 17:17:59 +0200 Subject: [PATCH] Use reflection to infer the arguments of a Python user procedure --- platypush/plugins/inspect/_serialize.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/inspect/_serialize.py b/platypush/plugins/inspect/_serialize.py index 0a57c7cf1..a9b75258b 100644 --- a/platypush/plugins/inspect/_serialize.py +++ b/platypush/plugins/inspect/_serialize.py @@ -1,3 +1,4 @@ +import inspect import json @@ -10,7 +11,13 @@ class ProcedureEncoder(json.JSONEncoder): if callable(o): return { 'type': 'native_function', - 'source': f'{o.__module__}.{o.__name__}', + 'module': o.__module__, + 'source': inspect.getsourcefile(o), + 'args': [ + name + for name, arg in inspect.signature(o).parameters.items() + if arg.kind != arg.VAR_KEYWORD + ], } return super().default(o)