Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
gh-104003: Implement PEP 702#104004
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
gh-104003: Implement PEP 702#104004
Changes fromall commits
Commits
Show all changes
25 commits Select commitHold shift + click to select a range
93e11d6
gh-104003: Implement PEP 702
JelleZijlstrad8d3157
blurb
JelleZijlstra342f28b
Add more tests
JelleZijlstra9b167e8
describe runtime behavior
JelleZijlstra0ed9d41
steal the typing-extensions wording instead, it's better
JelleZijlstra2f69b4e
Merge remote-tracking branch 'upstream/main' into pep702
JelleZijlstra815591b
Put it in warnings, copy over from typing-extensions
JelleZijlstra4098e62
docs
JelleZijlstrad6625b9
fix test
JelleZijlstra0870a16
Update Doc/library/warnings.rst
JelleZijlstra2b48983
Merge branch 'main' into pep702
JelleZijlstrab9507bd
Code review
JelleZijlstra2f23654
Merge branch 'main' into pep702
JelleZijlstraed9a10c
make it a class
JelleZijlstra6ab4584
Merge remote-tracking branch 'upstream/main' into pep702
JelleZijlstrae60ad5c
Merge remote-tracking branch 'upstream/main' into pep702
JelleZijlstrad528dc8
Forward-port typing-extensions change
JelleZijlstrae323502
Add test suggested by Alex
JelleZijlstraacf49b3
Adjust docs
JelleZijlstra1d663ef
Add to Whats New
JelleZijlstrab94255d
Now that this is semi-public, use a better name
JelleZijlstrae7a361b
sync docstring
JelleZijlstra08efe4d
Update error msg
JelleZijlstraf4eb075
Apply suggestions from code review
AlexWaygoodc02f66f
Update Lib/warnings.py
JelleZijlstraFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
50 changes: 50 additions & 0 deletionsDoc/library/warnings.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -522,6 +522,56 @@ Available Functions | ||
and calls to :func:`simplefilter`. | ||
.. decorator:: deprecated(msg, *, category=DeprecationWarning, stacklevel=1) | ||
Decorator to indicate that a class, function or overload is deprecated. | ||
When this decorator is applied to an object, | ||
deprecation warnings may be emitted at runtime when the object is used. | ||
:term:`static type checkers <static type checker>` | ||
will also generate a diagnostic on usage of the deprecated object. | ||
Usage:: | ||
AlexWaygood marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
from warnings import deprecated | ||
from typing import overload | ||
@deprecated("Use B instead") | ||
class A: | ||
pass | ||
@deprecated("Use g instead") | ||
def f(): | ||
pass | ||
@overload | ||
@deprecated("int support is deprecated") | ||
def g(x: int) -> int: ... | ||
@overload | ||
def g(x: str) -> int: ... | ||
The warning specified by *category* will be emitted at runtime | ||
on use of deprecated objects. For functions, that happens on calls; | ||
for classes, on instantiation and on creation of subclasses. | ||
If the *category* is ``None``, no warning is emitted at runtime. | ||
The *stacklevel* determines where the | ||
warning is emitted. If it is ``1`` (the default), the warning | ||
is emitted at the direct caller of the deprecated object; if it | ||
is higher, it is emitted further up the stack. | ||
Static type checker behavior is not affected by the *category* | ||
and *stacklevel* arguments. | ||
The deprecation message passed to the decorator is saved in the | ||
``__deprecated__`` attribute on the decorated object. | ||
If applied to an overload, the decorator | ||
must be after the :func:`@overload <typing.overload>` decorator | ||
for the attribute to exist on the overload as returned by | ||
:func:`typing.get_overloads`. | ||
.. versionadded:: 3.13 | ||
See :pep:`702`. | ||
Available Context Managers | ||
-------------------------- | ||
9 changes: 9 additions & 0 deletionsDoc/whatsnew/3.13.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
282 changes: 281 additions & 1 deletionLib/test/test_warnings/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.