[issue28609] argparse claims '*' positional argument is required in error output

2021-12-10 Thread Irit Katriel
Irit Katriel added the comment: Reproduced on 3.11. >>> parser.parse_args([]) usage: [-h] [-V] COMMAND [ARGUMENT ...] : error: the following arguments are required: COMMAND, ARGUMENT -- nosy: +iritkatriel versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.5 ___

[issue28609] argparse claims '*' positional argument is required in error output

2019-05-27 Thread Stephen McDowell
Stephen McDowell added the comment: > For optionals, `required` is set by the programmer. But for positionals it > is set with: ... > So for '?' argument, required is False. But for '*', it must also have a > 'default' parameter (not just the default None). > So the proposed patch is overri

[issue28609] argparse claims '*' positional argument is required in error output

2017-02-27 Thread Ben Hoyt
Ben Hoyt added the comment: I definitely agree with Reuben here -- I just ran into this issue while creating a "production quality" tool, and the help message produced by argparse with nargs='*' confused me too. It's pretty clear that this is a simple bug in argparse's production of that usage

[issue28609] argparse claims '*' positional argument is required in error output

2017-02-27 Thread Ben Hoyt
Changes by Ben Hoyt : -- nosy: +benhoyt ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org

[issue28609] argparse claims '*' positional argument is required in error output

2016-11-07 Thread Reuben Thomas
Reuben Thomas added the comment: Thanks, that's a simple, robust workaround. I'll duck out now and leave the Python experts to sort out the underlying problem, if they can; I think it's still well worth sorting out, though documenting the problem and workaround would be much better than nothin

[issue28609] argparse claims '*' positional argument is required in error output

2016-11-06 Thread paul j3
paul j3 added the comment: My suggestion to use `metavar=('A','')` to streamline the usage creates problems with the help code http://bugs.python.org/issue14074 The tuple metavar does not work right for positionals. That's a old issue that should have been fixed long ago. So streamlining th

[issue28609] argparse claims '*' positional argument is required in error output

2016-11-06 Thread paul j3
paul j3 added the comment: Simply including a `default` parameter, even with the default default None, changes the error message In [395]: parser=argparse.ArgumentParser() In [396]: parser.add_argument('cmd'); In [397]: a=parser.add_argument('args',nargs='*',default=None) In

[issue28609] argparse claims '*' positional argument is required in error output

2016-11-06 Thread Reuben Thomas
Reuben Thomas added the comment: > Try `nargs='?'` or try providing a `default` along with the '*'. Why would I do that? I want 0 or more arguments, and there's no default value. > Including your ARGUMENT action in the error message is intentional. It will likely confuse the user. The syntax m

[issue28609] argparse claims '*' positional argument is required in error output

2016-11-06 Thread paul j3
paul j3 added the comment: Try `nargs='?'` or try providing a `default` along with the '*'. Including your ARGUMENT action in the error message is intentional. The test for this error message is: required_actions = [] for action in self._actions: if action not in se

[issue28609] argparse claims '*' positional argument is required in error output

2016-11-06 Thread paul j3
paul j3 added the comment: The current error message is the result of http://bugs.python.org/issue10424 and http://bugs.python.org/issue12776 Before the test was just: if positionals: self.error(_('too few arguments')) The 2nd patch reworked the test to include the revised handling

[issue28609] argparse claims '*' positional argument is required in error output

2016-11-04 Thread Reuben Thomas
Reuben Thomas added the comment: Thanks very much for this. It would be great if the redundancy I referred to in the usage message could also be removed, so that instead of "[ARGUMENT [ARGUMENT ...]]" it just said "[ARGUMENT ...]". (Similarly, for a '+' argument, it could say just ARGUMENT ..

[issue28609] argparse claims '*' positional argument is required in error output

2016-11-04 Thread Charlie Proctor
Charlie Proctor added the comment: I agree that the message is slightly misleading. Uploading one possible solution. I'm sure someone more familiar with the library might have a better approach... -- keywords: +patch nosy: +charlie.proctor Added file: http://bugs.python.org/file45357/o

[issue28609] argparse claims '*' positional argument is required in error output

2016-11-04 Thread Reuben Thomas
New submission from Reuben Thomas: In Python 3.5.2, with a positional argument with nargs='*', running the program with no arguments gives an error like this: usage: caffeinate [-h] [-V] COMMAND [ARGUMENT [ARGUMENT ...]] caffeinate: error: the following arguments are required: COMMAND, ARGUMENT