From d2e869353e8fbc456bb57a611b7fa42ad705346e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 21 May 2021 18:02:42 -0400 Subject: [PATCH] pybind/mgr/mgr_module: infer non-positional args Once we have an Optional[bool], we can always transition to non-positional, since we never have a non-optional bool. Same goes for the 'format' arg. Signed-off-by: Sage Weil --- src/pybind/mgr/mgr_module.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index f78b45493b89..42469fc9a61e 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -331,6 +331,14 @@ class CLICommand(object): if arg == '_end_positional_': positional = False continue + if ( + arg == 'format' + or arg_spec[arg] is Optional[bool] + or arg_spec[arg] is bool + ): + # implicit switch to non-positional on any + # Optional[bool] or the --format option + positional = False assert arg in arg_spec, \ f"'{arg}' is not annotated for {f}: {full_argspec}" has_default = index >= first_default -- 2.47.3