]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-26510: Add versionchanged for required arg of add_subparsers (GH-16588)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 7 Oct 2019 02:14:49 +0000 (19:14 -0700)
committerNed Deily <nad@python.org>
Mon, 14 Oct 2019 20:53:27 +0000 (16:53 -0400)
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@gmail.com>
Doc/library/argparse.rst
Doc/whatsnew/3.7.rst

index cef197f30555818d539db7b3d587251f640bf4ac..a2baa077cd890f2df1fb1f02c937c1e3dcd1de74 100644 (file)
@@ -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
 ^^^^^^^^^^^^^^^^
index 54c7b8f37da90925884fd413c3aa5489bf23cf5c..f6476a30f889f5c69d5d9812d84b4ecaca395c90 100644 (file)
@@ -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`.)