]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/mgr_module: preserve the signature of wrapped func
authorKefu Chai <kchai@redhat.com>
Wed, 13 Jan 2021 11:28:48 +0000 (19:28 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 15 Jan 2021 01:50:53 +0000 (09:50 +0800)
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 <kchai@redhat.com>
src/pybind/mgr/mgr_module.py

index 90666a931dfdbbfcc4a80506a2d04f0117b27f1f..08b59f5025e892525d1814514ce36d4516b77181 100644 (file)
@@ -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):