]> granicus.if.org Git - python/commitdiff
bpo-26510: Add versionchanged for required arg of add_subparsers (GH-16588)
authorAdam J. Stewart <ajstewart426@gmail.com>
Mon, 7 Oct 2019 02:08:48 +0000 (21:08 -0500)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 7 Oct 2019 02:08:48 +0000 (19:08 -0700)
The `required` argument to `argparse.add_subparsers` was added in #3027. This PR specifies the earliest version of Python where it is available.

https://bugs.python.org/issue26510

Automerge-Triggered-By: @merwok
Doc/library/argparse.rst
Doc/whatsnew/3.7.rst

index a8aeca41a70a6cd89a7a02bb09706384eb50661c..00115d5cd1e9bd72795d2992399f21418cbaa114 100644 (file)
@@ -1636,7 +1636,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``
 
@@ -1792,6 +1792,9 @@ Sub-commands
      >>> parser.parse_args(['2', 'frobble'])
      Namespace(subparser_name='2', y='frobble')
 
+   .. versionchanged:: 3.7
+      New *required* keyword argument.
+
 
 FileType objects
 ^^^^^^^^^^^^^^^^
index af7e22d9faa9e427026deef9818350ddfdbe1a7b..1ec8e0c04c76ba2ef3639ee6a792045e9ddbce42 100644 (file)
@@ -2401,6 +2401,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`.)