mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
#10424: argument names are now included in the missing argument message
Fix and initial test patch by Michele Orrù.
This commit is contained in:
parent
8dd8d582e3
commit
f97c59aaba
3 changed files with 69 additions and 10 deletions
|
@ -1969,17 +1969,12 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||
# if we didn't consume all the argument strings, there were extras
|
||||
extras.extend(arg_strings[stop_index:])
|
||||
|
||||
# if we didn't use all the Positional objects, there were too few
|
||||
# arg strings supplied.
|
||||
if positionals:
|
||||
self.error(_('too few arguments'))
|
||||
|
||||
# make sure all required actions were present
|
||||
for action in self._actions:
|
||||
if action.required:
|
||||
if action not in seen_actions:
|
||||
name = _get_action_name(action)
|
||||
self.error(_('argument %s is required') % name)
|
||||
required_actions = [_get_action_name(action) for action in self._actions
|
||||
if action.required and action not in seen_actions]
|
||||
if required_actions:
|
||||
self.error(_('the following arguments are required: %s') %
|
||||
', '.join(required_actions))
|
||||
|
||||
# make sure all required groups had one option present
|
||||
for group in self._mutually_exclusive_groups:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue