Message387499
I've added a script that does what you want, but with a simple utility function instead of a parent (or lots of copy-n-paste).
====
I explored the code a bit, and have an idea that might correct the [parent] behavior.
In the method that copies a parent's groups and actions
def _add_container_actions(self, container):
It might be enough to change
for group in container._mutually_exclusive_groups:
mutex_group = self.add_mutually_exclusive_group(
required=group.required)
to
for group in container._mutually_exclusive_groups:
pgroup = group._container
mutex_group = pgroup.add_mutually_exclusive_group(
required=group.required)
The mutually group records where it was create in its '._container' attribute. Usually that would a parser, but in your example would the 'inputs' action group.
I haven't tested this idea.
====
In https://bugs.python.org/issue11588 (request for inclusive groups), I explored adding a Usage_Group class that could nest. That project become too large, especially when considering help formatting. And I did not give any thought to dealing with parents there.
====
Another issue involving parents (and the potential problems caused by copy-by-reference).
https://bugs.python.org/issue22401
argparse: 'resolve' conflict handler damages the actions of the parent parser
====
Belatedly I look for other issues involving 'parent', and found these duplicates
https://bugs.python.org/issue25882
argparse help error: arguments created by add_mutually_exclusive_group() are shown outside their parent group created by add_argument_group()
https://bugs.python.org/issue16807
argparse group nesting lost on inheritance |
|
Date |
User |
Action |
Args |
2021-02-22 05:30:13 | paul.j3 | set | recipients:
+ paul.j3, rhettinger, calestyo |
2021-02-22 05:30:13 | paul.j3 | set | messageid: <1613971813.31.0.679939675278.issue43259@roundup.psfhosted.org> |
2021-02-22 05:30:13 | paul.j3 | link | issue43259 messages |
2021-02-22 05:30:13 | paul.j3 | create | |
|