-
-
Notifications
You must be signed in to change notification settings - Fork 910
Add a guide to deprecating features #1469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f2fd360
e99387d
be9224b
b8fbd0b
207294f
a90e99a
fc0b4ec
7029868
0dc75ec
0d8bd61
d077a58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,90 @@ | ||||||
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. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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`. | ||||||
|
||||||
Check prevalence and consider alternatives | ||||||
------------------------------------------ | ||||||
|
||||||
Before proposing deprecation: | ||||||
|
||||||
* **Assess Usage**: Use tools like GitHub search, `grep`_, or `PyPI statistics`_ to determine the extent and context of usage. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a link to the GitHub search and list Victor's script: https://hugovk.dev/blog/2022/how-to-search-5000-python-projects/ ? |
||||||
* **Consider Alternatives**: Ensure there are suitable replacements or upgrades available. | ||||||
|
||||||
.. _grep: https://www.gnu.org/software/grep/ | ||||||
.. _PyPI statistics: https://pypistats.org/ | ||||||
|
||||||
Open an issue | ||||||
------------- | ||||||
|
||||||
Start by creating a GitHub issue to propose the deprecation: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||||||
|
||||||
Deprecation implementation | ||||||
-------------------------- | ||||||
|
||||||
Once approved: | ||||||
|
||||||
* **Raise a Warning**: Use ``warnings._deprecated`` with :exc:`DeprecationWarning` for typical cases. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this preferred over the documented and more common |
||||||
If the feature is in its early deprecation phase: | ||||||
|
||||||
* Use :exc:`PendingDeprecationWarning` initially, which transitions to :exc:`DeprecationWarning` after a suitable period. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We rarely use |
||||||
|
||||||
Example: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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._deprecated( | ||||||
"Feature X is deprecated and will be removed in Python 3.Y", | ||||||
DeprecationWarning, | ||||||
stacklevel=2 | ||||||
) | ||||||
|
||||||
* **Update Documentation**: | ||||||
|
||||||
* Add a deprecation note in the relevant docstrings. | ||||||
* Include details in the "Porting" section of the "What's New" documentation. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* Update the ``pending-removal-in-{version}.rst`` file with the deprecation timeline. | ||||||
|
||||||
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. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
These are not used in CPython? |
||||||
|
||||||
Plan removal | ||||||
------------ | ||||||
|
||||||
After the deprecation period (not less than two 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. | ||||||
|
||||||
``PendingDeprecationWarning`` workflow | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This stage seems odd, how often is this done? |
||||||
-------------------------------------- | ||||||
|
||||||
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. | ||||||
|
||||||
References and templates | ||||||
------------------------ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can also link to PEP 4 |
||||||
|
||||||
* Use the ``.. deprecated-removed::`` roles for documentation. | ||||||
* Add ``See Also`` links to :pep:`387` and DevGuide for policy and process details. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand, do you suggest a |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ Development workflow | |
:maxdepth: 5 | ||
|
||
communication-channels | ||
cpython-deprecation-workflow | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should definitely be below |
||
development-cycle | ||
stdlib | ||
extension-modules | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.