Author paul.j3
Recipients andrewnester, berker.peksag, bethard, brian.curtin, christofsteel, paul.j3
Date 2017-02-22.20:24:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1487795081.15.0.263185499268.issue29553@psf.upfronthosting.co.za>
In-reply-to
Content
http://bugs.python.org/issue22047 "argparse improperly prints mutually exclusive options when they are in a group"

is similar.

-----

There are two issues:

- the nesting of mutually exclusive groups

- the formatting of the usage in such cases.

Both have come up in one way or other in other bug reports.

Yes, it is possible to add a group to an existing group.  But from a testing standpoint the effect is the same as if you put all actions into one super group. 

More often people try to nest ArgumentGroups in MutuallyExclusiveGroups thinking that would give some sort of 'any' or 'and' logic within the 'xor' logic.  I have explored that in 

http://bugs.python.org/issue11588.  

Defining nestable groups is relatively easy.  Writing good usage is much harder.
 
The usage formatter is brittle.  It creates a big string, strips out 'excess' characters (the problem here), and then splits and reassembles the string (leading to assertion errors if the metavars contain funny characters).

In 

http://bugs.python.org/issue11874  

I submitted a patch that substantially rewrites the usage formatter.  The idea was to keep the action strings separate until the last moment.  While I haven't tested it with the current problem, I did use it in my nested-groups coding.

While I'm not opposed to patching the usage formatting in bits and pieces, we should do so while fully aware of the big picture.  Little patches tend to make brittle code even more brittle.
History
Date User Action Args
2017-02-22 20:24:41paul.j3setrecipients: + paul.j3, bethard, brian.curtin, berker.peksag, andrewnester, christofsteel
2017-02-22 20:24:41paul.j3setmessageid: <1487795081.15.0.263185499268.issue29553@psf.upfronthosting.co.za>
2017-02-22 20:24:41paul.j3linkissue29553 messages
2017-02-22 20:24:41paul.j3create