[Python-checkins] bpo-26510: Add versionchanged for required arg of add_subparsers (GH-16588)
Miss Islington (bot)
webhook-mailer at python.org
Sun Oct 6 22:14:54 EDT 2019
https://github.com/python/cpython/commit/50b8d579421e621130806e62d6108f5f83d4be7f
commit: 50b8d579421e621130806e62d6108f5f83d4be7f
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-10-06T19:14:49-07:00
summary:
bpo-26510: Add versionchanged for required arg of add_subparsers (GH-16588)
The `required` argument to `argparse.add_subparsers` was added in GH-3027. This PR specifies the earliest version of Python where it is available.
https://bugs.python.org/issue26510
Automerge-Triggered-By: @merwok
(cherry picked from commit 9e71917e0290972f65711f75510078f799cf0b59)
Co-authored-by: Adam J. Stewart <ajstewart426 at gmail.com>
files:
M Doc/library/argparse.rst
M Doc/whatsnew/3.7.rst
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index cef197f305558..a2baa077cd890 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -1583,7 +1583,7 @@ Sub-commands
stored; by default ``None`` and no value is stored
* required_ - Whether or not a subcommand must be provided, by default
- ``False``.
+ ``False`` (added in 3.7)
* help_ - help for sub-parser group in help output, by default ``None``
@@ -1739,6 +1739,9 @@ Sub-commands
>>> parser.parse_args(['2', 'frobble'])
Namespace(subparser_name='2', y='frobble')
+ .. versionchanged:: 3.7
+ New *required* keyword argument.
+
FileType objects
^^^^^^^^^^^^^^^^
diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst
index 54c7b8f37da90..f6476a30f889f 100644
--- a/Doc/whatsnew/3.7.rst
+++ b/Doc/whatsnew/3.7.rst
@@ -2414,6 +2414,10 @@ Changes in the Python API
instead of a :class:`bytes` instance.
(Contributed by Victor Stinner in :issue:`21071`.)
+* :mod:`argparse` subparsers can now be made mandatory by passing ``required=True``
+ to :meth:`ArgumentParser.add_subparsers() <argparse.ArgumentParser.add_subparsers>`.
+ (Contributed by Anthony Sottile in :issue:`26510`.)
+
* :meth:`ast.literal_eval()` is now stricter. Addition and subtraction of
arbitrary numbers are no longer allowed.
(Contributed by Serhiy Storchaka in :issue:`31778`.)
More information about the Python-checkins
mailing list