Message 326127 - Python tracker

Message326127

Author paul.j3
Recipients Endre, berker.peksag, bethard, paul.j3, xiang.zhang
Date 2018-09-23.03:14:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1537672491.18.0.956365154283.issue26952@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-09-23 03:14:51paul.j3setrecipients: + paul.j3, bethard, berker.peksag, xiang.zhang, Endre
2018-09-23 03:14:51paul.j3setmessageid: <1537672491.18.0.956365154283.issue26952@psf.upfronthosting.co.za>
2018-09-23 03:14:51paul.j3linkissue26952 messages
2018-09-23 03:14:50paul.j3create