You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arguments in the nested group show up in the usage string, but not in the help text. The nested arguments are still parsed and available in the result, as normal.
Arguments in the nested group are not mutually exclusive with any arguments in the containing mutually_exclusive_group.
I would expect:
--b ok
--c ok
--d ok
--b --c error
--b --d error
--c --d error*
--b --c --d error
*From a design perspective, it seems like argument_groups are meant to control display, and mutually_exclusive_groups are meant to control logic, so I think "error" makes sense here. I personally would like the ability to allow "--c --d", but I think that's a separate discussion and probably a new type of group.
With one exception, groups are not designed or intended to be nested. But by inheritance (from _ActionsContainer) nesting isn't blocked nor does it raise any errors.
As you surmise, an ArgumentGroup, is used only for grouping the help lines. By default that are two groups, with 'optionals' and 'required' names (actually the later should be 'positional'). The rest are user defined. They don't affect parsing in any way.
MutuallyExclusiveGroup is used in parsing. It also is used, to the extent possible, when formatting usage.
If a MutuallyExclusiveGroup is nested inside another MutuallyExclusiveGroup the parsing effect is just one flat group. Usage can be messed up - that's been the subject of another bug/issue.
A MutuallyExclusiveGroup may be put in an ArgumentGroup. This is a way of giving the exclusive group a title and/or description in the help.
There is a bug/issue requesting some sort of inclusive group. I tried to develop such a patch, implementing nesting, complete logic control (not just the current xor). But the usage formatting needs a complete rewrite. Overall this is too complex of an addition. On StackOverFlow I tell people to implement their own post-parsing testing.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: