gh-91832: Add 'required' attr to argparse.Action repr (GH-91841)

# Adding 'required' to names in Lib.argparse.Action

gh-91832: 
Added 'required' to the list `names` in `Lib.argparse.Action`. 
Changed constant strings that test the Action object.

Automerge-Triggered-By: GH:merwok
This commit is contained in:
Abhigyan Bose 2022-04-28 20:20:27 +05:30 committed by GitHub
parent 6dcbc08c95
commit 4ed3900041
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -850,6 +850,7 @@ class Action(_AttributeHolder):
'default',
'type',
'choices',
'required',
'help',
'metavar',
]

View File

@ -4900,12 +4900,13 @@ class TestStrings(TestCase):
nargs='+',
default=42,
choices=[1, 2, 3],
required=False,
help='HELP',
metavar='METAVAR')
string = (
"Action(option_strings=['--foo', '-a', '-b'], dest='b', "
"nargs='+', const=None, default=42, type='int', "
"choices=[1, 2, 3], help='HELP', metavar='METAVAR')")
"choices=[1, 2, 3], required=False, help='HELP', metavar='METAVAR')")
self.assertStringEqual(option, string)
def test_argument(self):
@ -4916,12 +4917,13 @@ class TestStrings(TestCase):
nargs='?',
default=2.5,
choices=[0.5, 1.5, 2.5],
required=True,
help='H HH H',
metavar='MV MV MV')
string = (
"Action(option_strings=[], dest='x', nargs='?', "
"const=None, default=2.5, type=%r, choices=[0.5, 1.5, 2.5], "
"help='H HH H', metavar='MV MV MV')" % float)
"required=True, help='H HH H', metavar='MV MV MV')" % float)
self.assertStringEqual(argument, string)
def test_namespace(self):

View File

@ -0,0 +1 @@
Add ``required`` attribute to :class:`argparse.Action` repr output.