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:
Serhiy Storchaka 2024-10-12 14:46:28 +03:00 committed by GitHub
parent eb2d268ac7
commit a6c0c64de0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 2 deletions

View file

@ -5411,7 +5411,8 @@ class TestInvalidArgumentConstructors(TestCase):
parser.add_argument(dest='foo')
with self.assertRaises(ValueError) as cm:
parser.add_argument('bar', dest='baz')
self.assertIn('dest supplied twice for positional argument',
self.assertIn('dest supplied twice for positional argument,'
' did you mean metavar?',
str(cm.exception))
def test_no_argument_actions(self):