summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-04-28 15:19:07 (GMT)
committerGitHub <noreply@github.com>2022-04-28 15:19:07 (GMT)
commitfa87c362e1861aa1092c1dcd409b00ae25db7874 (patch)
tree000b77069ed3c60a741b0abce5c31aeaa806ca2d /Lib
parent0e16105af69ec33e1215e0543f26a33bc8d10a16 (diff)
downloadcpython-fa87c362e1861aa1092c1dcd409b00ae25db7874.zip
cpython-fa87c362e1861aa1092c1dcd409b00ae25db7874.tar.gz
cpython-fa87c362e1861aa1092c1dcd409b00ae25db7874.tar.bz2
gh-91832: Add 'required' attr to argparse.Action repr (GH-91841)
GH- 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 (cherry picked from commit 4ed3900041c688a02dca1eb3323083d720dd0d93) Co-authored-by: Abhigyan Bose <abhigyandeepbose@gmail.com>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/argparse.py1
-rw-r--r--Lib/test/test_argparse.py6
2 files changed, 5 insertions, 2 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index c46bb302..b9c2205 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -848,6 +848,7 @@ class Action(_AttributeHolder):
'default',
'type',
'choices',
+ 'required',
'help',
'metavar',
]
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index dcc392f..2d1cec1 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -4873,12 +4873,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):
@@ -4889,12 +4890,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):