Skip to content

Commit a560986

Browse files
committed
Remove getopt and optparse deprecation notices
1 parent d467d92 commit a560986

File tree

9 files changed

+80
-28
lines changed

9 files changed

+80
-28
lines changed

Doc/library/allos.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,9 @@ but they are available on most other systems as well. Here's an overview:
1515
os.rst
1616
io.rst
1717
time.rst
18-
argparse.rst
1918
logging.rst
2019
logging.config.rst
2120
logging.handlers.rst
22-
getpass.rst
23-
curses.rst
24-
curses.ascii.rst
25-
curses.panel.rst
2621
platform.rst
2722
errno.rst
2823
ctypes.rst

Doc/library/argparse.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111

1212
**Source code:** :source:`Lib/argparse.py`
1313

14+
.. note::
15+
16+
While :mod:`argparse` is the recommended standard library module for
17+
*implementing* command line applications, authors of third party
18+
command line argument processing libraries may find that the
19+
simpler :mod:`optparse` module serves as a better foundation for
20+
that use case.
21+
1422
--------------
1523

1624
.. sidebar:: Tutorial

Doc/library/cmdlinelibs.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. _cmdlinelibs:
2+
3+
**************************************
4+
Command Line Implementation Libraries
5+
**************************************
6+
7+
The modules described in this chapter provide interfaces that assist with
8+
implementing command line applications. Here's an overview:
9+
10+
.. toctree::
11+
:maxdepth: 1
12+
13+
argparse.rst
14+
optparse.rst
15+
getopt.rst
16+
getpass.rst
17+
curses.rst
18+
curses.ascii.rst
19+
curses.panel.rst

Doc/library/getopt.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77

88
**Source code:** :source:`Lib/getopt.py`
99

10-
.. deprecated:: 3.13
11-
The :mod:`getopt` module is :term:`soft deprecated` and will not be
12-
developed further; development will continue with the :mod:`argparse`
13-
module.
14-
1510
.. note::
1611

1712
The :mod:`getopt` module is a parser for command line options whose API is

Doc/library/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ the `Python Package Index <https://pypi.org>`_.
5555
fileformats.rst
5656
crypto.rst
5757
allos.rst
58+
cmdlinelibs.rst
5859
concurrency.rst
5960
ipc.rst
6061
netdata.rst

Doc/library/optparse.rst

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,38 @@
1010

1111
**Source code:** :source:`Lib/optparse.py`
1212

13-
.. deprecated:: 3.2
14-
The :mod:`optparse` module is :term:`soft deprecated` and will not be
15-
developed further; development will continue with the :mod:`argparse`
16-
module.
13+
.. note::
14+
15+
:mod:`argparse` (rather than this module) is the recommended standard
16+
library module for implementing command line applications unless one
17+
of the following caveats applies:
18+
19+
* the application requires additional control over the way options and
20+
positional parameters are interleaved on the command line (including
21+
the ability to disable the interleaving feature completely)
22+
* the application requires additional control over the incremental parsing
23+
of command line elements (while ``argparse`` does support this, the
24+
exact way it will work in practice is sometimes unpredictable)
25+
* the application requires additional control over the handling of options
26+
which accept parameter values that may start with ``-`` (such as delegated
27+
options to be passed to invoked subprocesses).
28+
29+
These ``argparse`` caveats also mean that :mod:`optparse` is likely to
30+
provide a better foundation for library authors *writing* third party
31+
command line argument processing libraries.
32+
33+
.. seealso::
34+
35+
The :pypi:`"click" package <click>` is an ``optparse`` based third party
36+
argument processing library which allows command line applications to be
37+
developed as a set of appropriately decorated command implementation
38+
functions.
39+
40+
.. seealso::
41+
42+
The :pypi:`"Typer" package <click>` is a ``click`` based third party
43+
argument processing library which allows the use of annotated Python
44+
type hints to define an application's command line interface.
1745

1846
--------------
1947

Doc/library/superseded.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,5 @@ Superseded Modules
77
The modules described in this chapter are deprecated or :term:`soft deprecated` and only kept for
88
backwards compatibility. They have been superseded by other modules.
99

10-
11-
.. toctree::
12-
:maxdepth: 1
13-
14-
getopt.rst
15-
optparse.rst
10+
With the removal of various obsolete modules through :pep:`594`, there are currently no modules
11+
in this category.

Doc/whatsnew/3.13.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,18 @@ opcode
16481648
(Contributed by Irit Katriel in :gh:`105481`.)
16491649

16501650

1651+
optparse
1652+
--------
1653+
1654+
* This module is no longer considered :term:`soft deprecated`.
1655+
While :mod:`argparse` remains preferred for new projects that
1656+
aren't using a third party command line argument processing
1657+
library, there are aspects of the way ``argparse`` works that
1658+
means ``optparse`` may provide a better foundation for *writing*
1659+
argument processing libraries.
1660+
(Contributed by Alyssa Coghlan in :gh:`126225`.)
1661+
1662+
16511663
pathlib
16521664
-------
16531665

@@ -1787,14 +1799,6 @@ New Deprecations
17871799
Check membership in :data:`~dis.hasarg` instead.
17881800
(Contributed by Irit Katriel in :gh:`109319`.)
17891801

1790-
* :mod:`getopt` and :mod:`optparse`:
1791-
1792-
* Both modules are now :term:`soft deprecated`,
1793-
with :mod:`argparse` preferred for new projects.
1794-
This is a new soft-deprecation for the :mod:`!getopt` module,
1795-
whereas the :mod:`!optparse` module was already *de facto* soft deprecated.
1796-
(Contributed by Victor Stinner in :gh:`106535`.)
1797-
17981802
* :mod:`gettext`:
17991803

18001804
* Deprecate non-integer numbers as arguments to functions and methods
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
:mod:`getopt` and :mod:`optparse` are no longer marked as deprecated.
2+
There are legitimate reasons to use one of these modules in preference to
3+
:mod:`argparse`, and none of these modules are at risk of being removed
4+
from the standard library. Of the three, ``argparse`` remains the
5+
recommended default choice, *unless* one of the concerns noted at the top of
6+
the module documentation applies.

0 commit comments

Comments
 (0)