mirror of
https://github.com/python/cpython.git
synced 2025-08-25 11:15:02 +00:00
gh-61011: Fix inheritance of nested mutually exclusive groups in argparse (GH-125210)
Previously, all nested mutually exclusive groups lost their connection to the group containing them and were displayed as belonging directly to the parser. Co-authored-by: Danica J. Sutherland <djsutherland@users.noreply.github.com>
This commit is contained in:
parent
0135848059
commit
18c7449768
4 changed files with 39 additions and 1 deletions
|
@ -1521,7 +1521,11 @@ class _ActionsContainer(object):
|
|||
# NOTE: if add_mutually_exclusive_group ever gains title= and
|
||||
# description= then this code will need to be expanded as above
|
||||
for group in container._mutually_exclusive_groups:
|
||||
mutex_group = self.add_mutually_exclusive_group(
|
||||
if group._container is container:
|
||||
cont = self
|
||||
else:
|
||||
cont = title_group_map[group._container.title]
|
||||
mutex_group = cont.add_mutually_exclusive_group(
|
||||
required=group.required)
|
||||
|
||||
# map the actions to their new mutex group
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue