summaryrefslogtreecommitdiff
path: root/Lib/argparse.py
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2017-09-20 14:35:27 -0700
committerÉric Araujo <merwok@users.noreply.github.com>2017-09-20 17:35:27 -0400
commitaaf6fc0982c916cb71d9e0afcd7dda4ba495793b (patch)
tree09cb0078fade182a8be0a108bb50b57a71156bd9 /Lib/argparse.py
parent19e4d9346db7fb65845b98a9cb9caacaaac8a81a (diff)
downloadcpython-git-aaf6fc0982c916cb71d9e0afcd7dda4ba495793b.tar.gz
bpo-26510: make argparse subparsers required by default (#3027)
This fixes a regression from Python 2. To get optional subparsers, use the new parameter ``add_subparsers(required=False)``. Patch by Anthony Sottile.
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r--Lib/argparse.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index d59e645203..98bbed0e50 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -1066,6 +1066,7 @@ class _SubParsersAction(Action):
prog,
parser_class,
dest=SUPPRESS,
+ required=True,
help=None,
metavar=None):
@@ -1079,6 +1080,7 @@ class _SubParsersAction(Action):
dest=dest,
nargs=PARSER,
choices=self._name_parser_map,
+ required=required,
help=help,
metavar=metavar)