From 2715e7d5c90df89df57bd768a77f42feac630c47 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 11 Apr 2022 14:46:37 -0400 Subject: [PATCH] pybind/mgr: change to private _load_func_metadata classmethod The load_func_metadata had exactly one use in the codebase, the store_func_metadata method. It was also a staticmethod that referred to a property of it's class. This change makes the function "private" by renaming it to _load_func_metadata, removing it from the public "surface area" of the type. It changes it to a classmethod so that it would work correctly if used from a subclass of CLICommand. Signed-off-by: John Mulligan (cherry picked from commit 8c7876146bb7d579cd000049611ae999a8bc1963) --- src/pybind/mgr/mgr_module.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index d1076b51be81d..f8f85b7172d82 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -346,8 +346,8 @@ class CLICommand(object): KNOWN_ARGS = '_', 'self', 'mgr', 'inbuf', 'return' - @staticmethod - def load_func_metadata(f: HandlerFuncType) -> Tuple[str, Dict[str, Any], int, str]: + @classmethod + def _load_func_metadata(cls: Any, f: HandlerFuncType) -> Tuple[str, Dict[str, Any], int, str]: desc = (inspect.getdoc(f) or '').replace('\n', ' ') full_argspec = inspect.getfullargspec(f) arg_spec = full_argspec.annotations @@ -357,7 +357,7 @@ class CLICommand(object): args = [] positional = True for index, arg in enumerate(full_argspec.args): - if arg in CLICommand.KNOWN_ARGS: + if arg in cls.KNOWN_ARGS: continue if arg == '_end_positional_': positional = False @@ -381,7 +381,7 @@ class CLICommand(object): def store_func_metadata(self, f: HandlerFuncType) -> None: self.desc, self.arg_spec, self.first_default, self.args = \ - self.load_func_metadata(f) + self._load_func_metadata(f) def __call__(self, func: HandlerFuncType) -> HandlerFuncType: self.store_func_metadata(func) -- 2.39.5