gh-104003: Implement PEP 702#104004
Conversation
gvanrossum
left a comment
There was a problem hiding this comment.
LGTM.
Sorry, something went wrong.
gvanrossum
left a comment
There was a problem hiding this comment.
Waiting for the other reviewers to pipe in? This seems pretty straightforward.
Sorry, something went wrong.
The PEP hasn't been accepted yet! |
Sorry, something went wrong.
|
Planning to hit the merge button the moment the PEP is accepted :) |
Sorry, something went wrong.
|
PEP 702 has been accepted, but it's changed since this PR. I'll update the PR soon to put the decorator in |
Sorry, something went wrong.
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Got it. What if we did something like this? diff --git a/Lib/warnings.py b/Lib/warnings.py
index 36da0e75c6..fc8a10e71f 100644
--- a/Lib/warnings.py
+++ b/Lib/warnings.py
@@ -621,6 +621,7 @@ def wrapper(*args, **kwargs):
f"a class or callable, not {arg!r}"
)
+ decorator.__origin__ = deprecated
return decoratorThen third-party code could do checks like this: from typing import get_origin
from warnings import decorated
if get_origin(obj) is deprecated:
... # it was a wrapper function returned by `warnings.deprecated("message")` |
Sorry, something went wrong.
|
Doesn't seem to be |
Sorry, something went wrong.
It's already sorta awkwardly overloaded in what it means tbh — the |
Sorry, something went wrong.
|
A class seems somewhat more elegant to me, but yeah, that would work. |
Sorry, something went wrong.
|
I'm OK with making it a class. It's not what the object is meant for, but it's a reasonable extension. Using |
Sorry, something went wrong.
|
Thanks @AlexWaygood for the review! I pushed some changes. |
Sorry, something went wrong.
AlexWaygood
left a comment
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
edited by bedevere-bot
LoadingUh oh!
There was an error while loading. Please reload this page.
Copy link Copy MarkdownSorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.