paul j3 <ajipa...@gmail.com> added the comment:

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

----------
Added file: https://bugs.python.org/file49827/issue43259_utility.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43259>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to