Message187132
It does shift the error from parse_args to add_argument, but the message 'ValueError: length of metavar tuple does not match nargs', indicates that it's a side effect of checking on the tuple form of `metavar`.
http://bugs.python.org/issue9348
There is still room for cleaning up these tests. There are 2 functions that define what are acceptable values for nargs, [None, OPTIONAL, ZERO_OR_MORE, ONE_OR_MORE, REMAINDER, PARSER, integer]. Should one or other explicitly check nargs is an integer if it does not match one of the other strings?
And the test in _ActionContainer.add_argument()
# raise an error if the metavar does not match the type
if hasattr(self, "_get_formatter"):
try:
self._get_formatter()._format_args(action, None)
except TypeError:
raise ValueError("length of metavar tuple does not match nargs")
uses an ArgumentParser._get_formatter method (though 'hasattr' prevents runtime errors). In fact both functions that use nargs belong to the parser, not the container. I wonder if `add_argument` should be moved to ArgumentParser. |
|
Date |
User |
Action |
Args |
2013-04-17 03:12:25 | paul.j3 | set | recipients:
+ paul.j3, bethard, ned.deily, eric.araujo, Jason.Baker, BreamoreBoy |
2013-04-17 03:12:25 | paul.j3 | set | messageid: <1366168345.85.0.422682278136.issue9849@psf.upfronthosting.co.za> |
2013-04-17 03:12:25 | paul.j3 | link | issue9849 messages |
2013-04-17 03:12:25 | paul.j3 | create | |
|