Skip to content

Commit 9e71917

Browse files
adamjstewartmiss-islington
authored andcommitted
bpo-26510: Add versionchanged for required arg of add_subparsers (GH-16588)
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
1 parent 24ddd9c commit 9e71917

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Doc/library/argparse.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,7 @@ Sub-commands
16361636
stored; by default ``None`` and no value is stored
16371637

16381638
* required_ - Whether or not a subcommand must be provided, by default
1639-
``False``.
1639+
``False`` (added in 3.7)
16401640

16411641
* help_ - help for sub-parser group in help output, by default ``None``
16421642

@@ -1792,6 +1792,9 @@ Sub-commands
17921792
>>> parser.parse_args(['2', 'frobble'])
17931793
Namespace(subparser_name='2', y='frobble')
17941794

1795+
.. versionchanged:: 3.7
1796+
New *required* keyword argument.
1797+
17951798

17961799
FileType objects
17971800
^^^^^^^^^^^^^^^^

Doc/whatsnew/3.7.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,6 +2401,10 @@ Changes in the Python API
24012401
instead of a :class:`bytes` instance.
24022402
(Contributed by Victor Stinner in :issue:`21071`.)
24032403

2404+
* :mod:`argparse` subparsers can now be made mandatory by passing ``required=True``
2405+
to :meth:`ArgumentParser.add_subparsers() <argparse.ArgumentParser.add_subparsers>`.
2406+
(Contributed by Anthony Sottile in :issue:`26510`.)
2407+
24042408
* :meth:`ast.literal_eval()` is now stricter. Addition and subtraction of
24052409
arbitrary numbers are no longer allowed.
24062410
(Contributed by Serhiy Storchaka in :issue:`31778`.)

0 commit comments

Comments
 (0)