[issue31360] argparse mutually_exclusive_group under add_argument_group fails if part of parent_processor
Paul Traina (discontent)
report at bugs.python.org
Tue Sep 5 23:42:16 EDT 2017
New submission from Paul Traina (discontent):
Hopefully I'm not being obtuse, but I seem to be getting incorrect/unexpected help output when using mutually_exclusive_group under an add_argument_group if this layering is happening in a parent parser.
Here's an example of the triggering usage:
import argparse
global_options = argparse.ArgumentParser(add_help=False)
global_options.add_argument('--summary', action='store_true', help='summarize information')
global_options.add_argument('--verbose', action='store_true', help='tell us more')
output_format = global_options.add_argument_group("Output format", "ways to foo")
styles = output_format.add_mutually_exclusive_group()
styles.add_argument('--plain', dest='style')
styles.add_argument('--green', dest='style')
styles.add_argument('--blue', dest='style')
parser = argparse.ArgumentParser()
commands = parser.add_subparsers()
hit = commands.add_parser('hit', parents=[global_options])
miss = commands.add_parser('miss', parents=[global_options])
print(parser.parse_args(['hit', '-h']))
which produces:
usage: bar.py hit [-h] [--summary] [--verbose]
[--plain STYLE | --green STYLE | --blue STYLE]
optional arguments:
-h, --help show this help message and exit
--summary summarize information
--verbose tell us more
--plain STYLE
--green STYLE
--blue STYLE
Output format:
ways to foo
"--plain" "--green" and "--blue" *should* be under "Output format"
----------
components: Library (Lib)
messages: 301437
nosy: Paul Traina (discontent)
priority: normal
severity: normal
status: open
title: argparse mutually_exclusive_group under add_argument_group fails if part of parent_processor
type: behavior
versions: Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31360>
_______________________________________
More information about the Python-bugs-list
mailing list