Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions developer-workflow/cpython-deprecation-workflow.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
Workflow for Deprecating Features in CPython
==============================================
Comment on lines +1 to +2
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Workflow for Deprecating Features in CPython
==============================================
Workflow for Deprecating Features in CPython
============================================


Deprecation in CPython is a multi-step process that involves notifying users about deprecated functionality, planning its eventual removal, and providing adequate guidance for migration.
Copy link
Member

Choose a reason for hiding this comment

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

Please wrap lines to 79 characters.

This document outlines the practical steps required for deprecating a feature, supplementing the policy guidelines defined in :pep:`387`.

1. Identify Features for Deprecation
------------------------------------
Before proposing deprecation:

* **Assess Usage**: Use tools like GitHub search, ``grep``, or ``PyPI statistics`` to determine the extent and context of usage.
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps you could add links here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay sure, let me add them

* **Consider Alternatives**: Ensure there are suitable replacements or upgrades available.

2. Open an Issue
----------------
Start by creating a GitHub issue to propose the deprecation:
Copy link
Member

Choose a reason for hiding this comment

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

I think we should recommend a thread on Discourse first?


* Clearly describe the feature and why deprecation is needed.
* Encourage community feedback and suggestions.

3. Deprecation Implementation
-----------------------------
Once approved:

* **Raise a Warning**: Use :func:`warnings.warn` with :exc:`DeprecationWarning` for typical cases.
If the feature is in its early deprecation phase:

* Use :exc:`PendingDeprecationWarning` initially, which transitions to :exc:`DeprecationWarning` after a suitable period.
Copy link
Member

Choose a reason for hiding this comment

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

We rarely use PendingDeprecationWarning, I think we can drop it?


Example:
Copy link
Member

Choose a reason for hiding this comment

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

This example would be more beneficial if an example feature existed, a function would add a lot IMO


.. code-block:: python

import warnings
warnings.warn(
"Feature X is deprecated and will be removed in Python 3.Y",
DeprecationWarning,
stacklevel=2
)
Copy link
Member

Choose a reason for hiding this comment

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

We should probably use warnings._deprecated() instead here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks let me work on this change


* **Update Documentation**:

* Add a deprecation note in the relevant docstrings.
* Include details in the "Porting" section of the "What's New" documentation.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Include details in the "Porting" section of the "What's New" documentation.
* Include details in the "New Deprecations" section of the "What's New" documentation.

* Update the ``pending-removal-in-{version}.rst`` file with the deprecation timeline.

4. Track Deprecations
---------------------
* **Monitor Usage**: After the release, observe community feedback. Deprecations may remain longer than the minimum period if low maintenance overhead is expected or usage is widespread.
* **Timeline Review**: Use GitHub milestones or specific deprecation tracking issues to manage timelines.
Copy link
Member

Choose a reason for hiding this comment

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

GitHub milestones

These are not used in CPython?


5. Plan Removal
---------------
After the deprecation period (typically 2+ releases):

* Open a new issue for removal.
* Follow removal steps:

* Remove the deprecated code and warnings.
* Update documentation, removing references to the deprecated feature.
* Include the removal in the "What's New" for the release.

6. PendingDeprecationWarning Workflow
-------------------------------------
For gradual deprecations:

* **Use Case**: When you want to signal future deprecation but not yet alert end-users.
* **Transition Timeline**:

* Move from :exc:`PendingDeprecationWarning` to :exc:`DeprecationWarning` after one or more releases.

* **Documentation**:

* Mention the pending deprecation in “What’s New.”
* No ``pending-removal-in`` entry is needed during this stage.

7. References and Templates
---------------------------
* Use ``.. deprecated::`` and ``.. removed::`` Sphinx roles for documentation.
* Add ``See Also`` links to :pep:`387` and DevGuide for policy and process details.
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand, do you suggest a .. see-also:: under every deprecated feature?

1 change: 1 addition & 0 deletions developer-workflow/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Development workflow
:maxdepth: 5

communication-channels
cpython-deprecation-workflow
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 definitely be below development cycle

development-cycle
stdlib
extension-modules
Expand Down
Loading