[issue17890] argparse: mutually exclusive groups full of suppressed args can cause AssertionErrors

paul j3 report at bugs.python.org
Fri May 3 07:23:25 CEST 2013


paul j3 added the comment:

In the test case: class TestMutuallyExclusiveManySuppressed
even with a short 'eggs' argument, there is a difference

Old usage would be:

usage: PROG [-h]  [--eggs EGGS]

new

usage: PROG [-h] [--eggs EGGS]

i.e. 2 v 1 space.  But extra spaces are not as dramatic a failure as an assertion error.

It would also be good to check what happens when there are 2 suppressed groups.  If the text before all trimming is:

[ -h ] [] () [ --eggs EGGS ]

does it reduce to?

[-h] [--eggs EGGS]

The old code would have left 3 spaces.

I can't think of a situation in which a user would want a (generated) usage line with multiple spaces.  If some sort of special formatting is needed, there is always the option of specifying an explicit usage line.

parser = ArugmentParser(usage='one \ttwo  \nthree   four')

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17890>
_______________________________________


More information about the Python-bugs-list mailing list