summaryrefslogtreecommitdiffstats
path: root/Lib/argparse.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-10-12 11:46:28 (GMT)
committerGitHub <noreply@github.com>2024-10-12 11:46:28 (GMT)
commita6c0c64de0ade400df7995f1e9480b6fc0f863aa (patch)
treed48eb4b42b7f9c0e04bd15fe4c4105b7694a2ce3 /Lib/argparse.py
parenteb2d268ac7480b5e2b4ffb9a644cad7ac75ae954 (diff)
downloadcpython-a6c0c64de0ade400df7995f1e9480b6fc0f863aa.zip
cpython-a6c0c64de0ade400df7995f1e9480b6fc0f863aa.tar.gz
cpython-a6c0c64de0ade400df7995f1e9480b6fc0f863aa.tar.bz2
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>
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r--Lib/argparse.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 208c182..64dbd71 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -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