Skip to content

Conversation

savannahostrowski
Copy link
Member

@savannahostrowski savannahostrowski commented Sep 23, 2024

…exit() (GH-123932)

(cherry picked from commit 5f5c0b9)


📚 Documentation preview 📚: https://cpython-previews--124356.org.readthedocs.build/

…arser.exit() (pythonGH-123932)

(cherry picked from commit 5f5c0b9)

Co-authored-by: Savannah Ostrowski <[email protected]>
Comment on lines 1442 to 1469

.. _deprecated:

deprecated
^^^^^^^^^^

During a project's lifetime, some arguments may need to be removed from the
command line. Before removing them, you should inform
your users that the arguments are deprecated and will be removed.
The ``deprecated`` keyword argument of
:meth:`~ArgumentParser.add_argument`, which defaults to ``False``,
specifies if the argument is deprecated and will be removed
in the future.
For arguments, if ``deprecated`` is ``True``, then a warning will be
printed to :data:`sys.stderr` when the argument is used::

>>> import argparse
>>> parser = argparse.ArgumentParser(prog='snake.py')
>>> parser.add_argument('--legs', default=0, type=int, deprecated=True)
>>> parser.parse_args([])
Namespace(legs=0)
>>> parser.parse_args(['--legs', '4']) # doctest: +SKIP
snake.py: warning: option '--legs' is deprecated
Namespace(legs=4)

.. versionadded:: 3.13


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be here.

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) September 23, 2024 18:29
@serhiy-storchaka serhiy-storchaka merged commit b370956 into python:3.12 Sep 23, 2024
24 checks passed
@savannahostrowski savannahostrowski deleted the backport-5f5c0b9-3.12 branch September 27, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants