From: Kefu Chai Date: Wed, 13 Jan 2021 11:28:48 +0000 (+0800) Subject: pybind/mgr/mgr_module: preserve the signature of wrapped func X-Git-Tag: v16.1.0~20^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b4c3801e9d6d4a97a85637a0b18fd782ae0ba9ed;p=ceph.git pybind/mgr/mgr_module: preserve the signature of wrapped func before this change, the annotations of the func wrapped by CLICheckNonemptyFileInput and returns_command_result are lost after being wrapped with this decorator. after this change, the parameter annotations are preserved. these annotations are used for generating the argdesc in a later commit. Signed-off-by: Kefu Chai --- diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 90666a931dfd..08b59f5025e8 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -408,6 +408,7 @@ def CLICheckNonemptyFileInput(func): and not kwargs['inbuf'].strip('\n')): return -errno.EINVAL, '', ERROR_MSG_EMPTY_INPUT_FILE return func(*args, **kwargs) + check.__signature__ = inspect.signature(func) # type: ignore[attr-defined] return check @@ -484,6 +485,7 @@ class Command(dict): def wrapper(mgr, *args, **kwargs): retval, stdout, stderr = f(instance or mgr, *args, **kwargs) return HandleCommandResult(retval, stdout, stderr) + wrapper.__signature__ = inspect.signature(f) # type: ignore[attr-defined] return wrapper def register(self, instance=False):