Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Lib/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,7 @@ def _get_kwargs(self):
'default',
'type',
'choices',
'required',
'help',
'metavar',
]
Expand Down
6 changes: 4 additions & 2 deletions Lib/test/test_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4900,12 +4900,13 @@ def test_optional(self):
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):
Expand All @@ -4916,12 +4917,13 @@ def test_argument(self):
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):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add 'required' attr to argparse.Action repr.
Comment thread
AbhigyanBose marked this conversation as resolved.
Outdated