This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul.j3
Recipients andrewnester, berker.peksag, bethard, brian.curtin, christofsteel, paul.j3
Date 2017-02-23.07:03:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I played around with the patch 117.  I was wrong in thinking this was another case of excess brackets being wrongly purged.  The fix works by adding ending ] that were missing the original.  And it does add a symmetry to the code.  

But it is easy to construct a set of Actions that creates further errors.  For the 'inserts' to work correctly the mutually exclusive Actions have to be defined together.  So all the actions of the nested group have to be defined after the non nest actions of the parent group.  An optional positional can also cause problems.

This whole _format_actions_usage method was not written with nested groups in mind.  While this patch fixes one or two cases, it isn't robust.

I also don't like the idea of enshrining group nesting in the file.  That fact that it works as well as it does is an accident, a feature, not an intentional behavior.

I haven't tested PR120 yet.  Dropping the inner brackets gives a cleaner display.  The nested brackets of 117 are hard to read, even if they are correct.  

Note that in I proposed blocking nested groups, by raising an error.

The reason why it is possible to add either kind of group to a _MutuallyExclusiveGroup is because it inherits the add methods from _ActionsContainer.  Normally those group add methods are used by ArgumentParser which also inherits from _ActionsContainer.

It is possible to add a MutuallyExclusiveGroup to an ArgumentGroup, and that is somewhat useful.  It doesn't change the usage, but does let you group that set of Actions in the help lines.  But this nesting is not fully developed, as hinted at by a commeent in the method that copies 'parents':

def _add_container_actions
        # add container's mutually exclusive groups
        # NOTE: if add_mutually_exclusive_group ever gains title= and
        # description= then this code will need to be expanded as above
Date User Action Args
2017-02-23 07:03:01paul.j3setrecipients: + paul.j3, bethard, brian.curtin, berker.peksag, andrewnester, christofsteel
2017-02-23 07:03:01paul.j3setmessageid: <>
2017-02-23 07:03:01paul.j3linkissue29553 messages
2017-02-23 07:03:00paul.j3create