mirror of
https://github.com/python/cpython.git
synced 2025-08-25 11:15:02 +00:00
gh-59330: Improve error message for dest= for positionals (GH-125215)
Also improve the documentation. Specify how dest and metavar are derived from add_argument() positional arguments. Co-authored-by: Simon Law <sfllaw@sfllaw.ca>
This commit is contained in:
parent
eb2d268ac7
commit
a6c0c64de0
3 changed files with 23 additions and 2 deletions
|
@ -1424,7 +1424,8 @@ class _ActionsContainer(object):
|
|||
chars = self.prefix_chars
|
||||
if not args or len(args) == 1 and args[0][0] not in chars:
|
||||
if args and 'dest' in kwargs:
|
||||
raise ValueError('dest supplied twice for positional argument')
|
||||
raise ValueError('dest supplied twice for positional argument,'
|
||||
' did you mean metavar?')
|
||||
kwargs = self._get_positional_kwargs(*args, **kwargs)
|
||||
|
||||
# otherwise, we're adding an optional argument
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue