[issue46057] argparse: embedded groups may prevent options from being in help output

László Attila Tóth report at bugs.python.org
Sun Dec 12 11:25:28 EST 2021


László Attila Tóth <laszlo.attila.toth at gmail.com> added the comment:

Sorry, these are two bugs in fact. The current one, the help with minmal code:

import argparse

parser = argparse.ArgumentParser()
grp = parser.add_argument_group('Database settings')
grp.add_argument('--db-config')
xgrp = grp.add_argument_group()
xgrp.add_argument('--db-password')
parser.parse_args(['-h'])


The group's help output shows only --db-config option:

Database settings:
  --db-config DB_CONFIG

If I change the xgrp to be mutually exclusive group as:
xgrp = grp.add_mutually_exclusive_group()

then the output is the same as I expect for the previous code, too:

Database settings:
  --db-config DB_CONFIG
  --db-password DB_PASSWORD

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46057>
_______________________________________


More information about the Python-bugs-list mailing list