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

paul j3 report at bugs.python.org
Sat Jan 1 21:12:21 EST 2022


paul j3 <ajipanca at gmail.com> added the comment:

Don't add an argument_group to another argument_group.  While input allows this nesting, the formatting is not designed to handle it.  Nor does the documentation illustrate such nesting.

Nesting a mutually_exclusive_group in an argument_group works because the exclusive_group is not used in formatting the help lines.  The two class of groups have very different purposes.

Note that the add_argument_group() method is defined for the parent _ActionsContainer class.  ArgumentParser inherits from this, as do both of the group classes.  While one could make a case for changing the group's inheritance of this method to Not-implemented, it's only a problem when users, like you, try to push for undocumented usage.

In general argparse has a clean and powerful class structure.  But it doesn't do a lot of checking and pruning, so there loose ends like this.  The Action class and its subclasses is similarly powerful, with enough loose ends to allow adventurous users to hang themselves :).

----------
nosy: +paul.j3

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


More information about the Python-bugs-list mailing list