paul j3 <ajipa...@gmail.com> added the comment:
If I add an argument to the mutexGroup as suggested by xiang In [7]: mutexGroup.add_argument('--foo', action='store_true') Out[7]: _StoreTrueAction(option_strings=['--foo'], dest='foo', nargs=0, const=True, default=False, type=None, choices=None, help=None, metavar=None) In [8]: parser.print_usage() usage: ipython3 [-h] -u URL -p PROJECT [--dump] --mergeInput MERGEINPUT [--removeDisabled] -c CHECKERS --foo In [9]: parser.print_help() usage: ipython3 [-h] -u URL -p PROJECT [--dump] --mergeInput MERGEINPUT [--removeDisabled] -c CHECKERS --foo Sets the checkers of a klocwork project optional arguments: -h, --help show this help message and exit -c CHECKERS, --checkers CHECKERS File which lists the checkers to be enabled. the argument_group arguments show up in the usage, but without mutually_exclusive markings. But they don't show up in the help lines. I suspect all those group arguments will be tested as one mutually exclusive group, not two subgroups. If I put the argument groups in the main parser, and omit the mutually_exclusive group I get this help: In [11]: parser.print_help() usage: ipython3 [-h] -u URL -p PROJECT [--dump] --mergeInput MERGEINPUT [--removeDisabled] -c CHECKERS Sets the checkers of a klocwork project optional arguments: -h, --help show this help message and exit -c CHECKERS, --checkers CHECKERS File which lists the checkers to be enabled. serverGroup: -u URL, --url URL klocwork server URL. -p PROJECT, --project PROJECT klocwork project name. --dump Dump the current checkers config. mergeGroup: --mergeInput MERGEINPUT Input file to merge for the '--checkers' file. Format: checkerName Enabled|Disabled --removeDisabled Disabled checkers will be removed from the '-- checkers' file. The argument groups appear as intended in the help lines. add_argument_group is inherited from _ActionsContainer. The parser ArgumentParser also inherits this method. A possible fix is to override this method in the _MutuallyExclusiveGroup class to raise some sort of not-implemented error. The documentation, as written, does not suggest or hint that an argument_group can be added to anything but a parser. But a stronger disclaimer could be added. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue26952> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com