From: Sage Weil Date: Fri, 21 May 2021 22:02:42 +0000 (-0400) Subject: pybind/mgr/mgr_module: infer non-positional args X-Git-Tag: v17.1.0~1726^2~16 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d2e869353e8fbc456bb57a611b7fa42ad705346e;p=ceph.git 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 --- 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