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
nargs can be one of several strings, e.g. '*', '...' (Const.PARSER) or an integer. But checking for valid values is ad hoc.
One issue is when or where nargs can be 0 or <0
parser.addArgument('foo',{nargs:0})
triggers an error by _StoreAction, saying that nargs should be >0. However
parser.addArgument('foo',{nargs:-1})
is accepted. parser.parseArgs([]) returns { foo: [] }, but formatUsage has problems formatting a metavar (in Javascript, not in the Python).
Another issue is what happens if nargs isn't one of the recognized strings or an integer (e.g. nargs:'1' or nargs:'test'). Neither Python or Javascript raises an error in addArgument. Instead the problems arise in either parseArgs or formatHelp. In both the ultimate issue is whether it can replicate a string nargs times.
In the most recent Python release, addArgument does test whether a tuple metavar matches nargs, and in the process discovers invalid nargs values. But even with this the error messages are not clear. Also parser.addArgument gets this test, but group.addArgument does not.
The text was updated successfully, but these errors were encountered:
Several python issues deal with nargs related error messages:
http://bugs.python.org/issue16970
argparse: bad nargs value raises misleading message
http://bugs.python.org/issue9849
Argparse needs better error handling for nargs
nargs can be one of several strings, e.g. '*', '...' (
Const.PARSER
) or an integer. But checking for valid values is ad hoc.One issue is when or where nargs can be 0 or <0
triggers an error by
_StoreAction
, saying that nargs should be >0. Howeveris accepted.
parser.parseArgs([])
returns{ foo: [] }
, butformatUsage
has problems formatting a metavar (in Javascript, not in the Python).Another issue is what happens if nargs isn't one of the recognized strings or an integer (e.g.
nargs:'1'
ornargs:'test'
). Neither Python or Javascript raises an error inaddArgument
. Instead the problems arise in eitherparseArgs
orformatHelp
. In both the ultimate issue is whether it can replicate a stringnargs
times.In the most recent Python release,
addArgument
does test whether atuple metavar
matchesnargs
, and in the process discovers invalidnargs
values. But even with this the error messages are not clear. Alsoparser.addArgument
gets this test, butgroup.addArgument
does not.The text was updated successfully, but these errors were encountered: