[issue9348] Calling argparse's add_argument with the wrong number of metavars causes delayed error message

2020-07-06 Thread daniel hahler
daniel hahler added the comment: This adds overhead, since it creates a formatter and uses it for formatting only for validation purposes. I think it is better to only have the error when the formatter is actually used (i.e. the help is displayed - which is not the typical use case, and it

[issue9348] Calling argparse's add_argument with the wrong number of metavars causes delayed error message

2011-03-26 Thread Roundup Robot
Roundup Robot devnull@devnull added the comment: New changeset c89db9b36ea6 by Steven Bethard in branch '3.2': Issue #9348: Raise an early error if argparse nargs and metavar don't match. http://hg.python.org/cpython/rev/c89db9b36ea6 New changeset b93a50bb74f2 by Steven Bethard in branch

[issue9348] Calling argparse's add_argument with the wrong number of metavars causes delayed error message

2011-03-26 Thread Steven Bethard
Steven Bethard steven.beth...@gmail.com added the comment: Thanks for the patch. I used something similar to what you proposed, but instead of creating a local formatter, I just call self._get_formatter() if it exists. -- assignee: - bethard nosy: -python-dev resolution: - fixed

[issue9348] Calling argparse's add_argument with the wrong number of metavars causes delayed error message

2011-03-26 Thread Denver Coneybeare
Denver Coneybeare denver.coneybe...@gmail.com added the comment: Awesome, thanks for committing the patch. Glad I could help. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9348 ___

[issue9348] Calling argparse's add_argument with the wrong number of metavars causes delayed error message

2011-03-19 Thread Denver Coneybeare
Denver Coneybeare denver.coneybe...@gmail.com added the comment: For kicks, I just took a look at this old, forgotten issue. I agree with the submitter that add_argument() should fail if nargs and metavar do not match, instead of having format_help() raise the exception later on. I've

[issue9348] Calling argparse's add_argument with the wrong number of metavars causes delayed error message

2010-08-04 Thread Steven Bethard
Steven Bethard steven.beth...@gmail.com added the comment: You can specify either 1 or N. So for n=3, you can specify metavar=X or metavar=(X, Y, Z) but not metavar=(X, Y). The special nargs value ? always takes only one, while * and + always take two. (This makes sense if you think about how

[issue9348] Calling argparse's add_argument with the wrong number of metavars causes delayed error message

2010-08-04 Thread Catherine Devlin
Catherine Devlin fredv8vi...@liquidid.net added the comment: Thanks for the correction, Steven. This unit test matches your description. Use it instead of my earlier submission. -- Added file: http://bugs.python.org/file18390/wrong_metavars_test_corrected.patch

[issue9348] Calling argparse's add_argument with the wrong number of metavars causes delayed error message

2010-08-02 Thread Catherine Devlin
Catherine Devlin fredv8vi...@liquidid.net added the comment: I'm attaching a unit test patch that does something vaguely like Steven suggests. It definitely needs review. Also, I'm assuming that it's OK to specify *fewer* metavars than nargs, just not more... but I'm not sure about that.

[issue9348] Calling argparse's add_argument with the wrong number of metavars causes delayed error message

2010-07-23 Thread Steven Bethard
New submission from Steven Bethard steven.beth...@gmail.com: What steps will reproduce the problem? parser = argparse.ArgumentParser() parser.add_argument('--foo', nargs=2, metavar=('X','Y','Z')) parser.parse_args(['-h']) The error dosn't show up until help is formatted. Giving any