From e6189427f3ba2d3899d49233a1accceab0d4611e Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 27 Dec 2020 22:46:59 +0800 Subject: [PATCH] pybind/mgr/orchestrator: do not pass cmd_args or desc to CLICommand anymore they will be attached to the handler function as annotations and docstring Signed-off-by: Kefu Chai --- src/pybind/mgr/orchestrator/_interface.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index 2542b92398d..fb752663820 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -84,7 +84,7 @@ def set_exception_subject(kind, subject, overwrite=False): raise -def handle_exception(prefix, cmd_args, desc, perm, func): +def handle_exception(prefix, perm, func): @wraps(func) def wrapper(*args, **kwargs): try: @@ -101,15 +101,16 @@ def handle_exception(prefix, cmd_args, desc, perm, func): # misuse partial to copy `wrapper` wrapper_copy = lambda *l_args, **l_kwargs: wrapper(*l_args, **l_kwargs) wrapper_copy._prefix = prefix # type: ignore - wrapper_copy._cli_command = CLICommand(prefix, cmd_args, desc, perm) # type: ignore + wrapper_copy._cli_command = CLICommand(prefix, perm) # type: ignore + wrapper_copy._cli_command.store_func_metadata(func) # type: ignore wrapper_copy._cli_command.func = wrapper_copy # type: ignore return wrapper_copy def _cli_command(perm): - def inner_cli_command(prefix, cmd_args="", desc=""): - return lambda func: handle_exception(prefix, cmd_args, desc, perm, func) + def inner_cli_command(prefix): + return lambda func: handle_exception(prefix, perm, func) return inner_cli_command -- 2.39.5