]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/mgr_module: infer non-positional args
authorSage Weil <sage@newdream.net>
Fri, 21 May 2021 22:02:42 +0000 (18:02 -0400)
committerSage Weil <sage@newdream.net>
Tue, 1 Jun 2021 18:45:11 +0000 (14:45 -0400)
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 <sage@newdream.net>
src/pybind/mgr/mgr_module.py

index f78b45493b893bf533b7e2f594d031af1b836070..42469fc9a61e26389ec41c40461f8aa3e6816d30 100644 (file)
@@ -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