-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
PEP 702: Type system support for deprecations #2942
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
Conversation
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.
I think it's somewhat unfortunate to not issue a runtime warning (I imagine most users would ideally want one). The SC has also indicated they'd like static typing to feel more cohesive with the runtime, so we should try harder to find something that could work.
Should we have an opt-in kwarg a la Protocol's runtime_checkable? Type checkers could warn if we decorate an overload with runtime warning; we could even detect it at runtime if the decorators are in the right order. Decorating a class could cause __init__
to raise the warning? (I think the popular deprecated library does this; can just use similar semantics)
(Let me know if I should move this comment to discuss or typing-sig; I just didn't see a discussion link in there) |
Thanks for the feedback, but yes I think this is better directed to the discuss/typing-sig thread. My plan is:
|
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.
Looks pretty good.
Though I actually think that introducing typing.Deprecated
would be something worth while, due to some additional uses it provides.
Mainly when deprecating type-aliases, like: FOO_TYPE: TypeAlias = Union[A, B, C]
, it would be quite nice to be able to mark this type alias as deprecated with: FOO_TYPE: Deprecated[TypeAlias, "Replaced by BAR_TYPE"] = Union[A, B, C]
. As this is currently completely impossible with the type system, and it's not even possible for a library to produce a runtime warning for these cases, which is why something like typing.Deprecated
would be very nice to see.
See PEP 702, python/peps#2942. This should not be merged until the PEP is merged into the repo.
Co-authored-by: Guido van Rossum <[email protected]>
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.
Various minor suggestions and comments.
Trying out the new PEP checklist:
New PEP Checklist
- File created from the latest PEP template
Content requirements
- PEP topic discussed in a suitable venue and general agreement that a PEP is appropriate
- Content is reasonably sound, complete and makes at least basic technical sense
- Abstract and Copyright sections completed, with the required wording in the latter
- Suggested sections included (unless not applicable)
- Title clearly, accurately and concisely describes the content [See comment]
- Prose is intelligible and generally free of basic grammar and syntax errors, at least to the degree they significantly detract from understanding [Except as listed in comments]
- Code is in code blocks, well-formatted (PEP 7/PEP 8) and has the right lexer name if non-Python (or
text
) -
Any project stated in the PEP as supporting/endorsing benefiting from it confirms suchNone found
Technical requirements
- Filename in the correct format (
pep-NNNN.rst
) -
PEP
,Title
,Author
,Status
(Draft
),Type
andCreated
headers filled out correctly -
PEP-Delegate
,Requires
,Python-Version
andReplaces
filled out if appropriate -
Sponsor
listed and approves if not authored by a core dev or PEP editor - PEP builds with no warnings, CI checks pass and content displays as intended in the rendered preview [Except for as listed in comments]
- PEP number assigned by the PEP editors and filename &
PEP
header updated accordingly - Sponsor/author(s) that are core devs/PEP editors added to
.github/CODEOWNERS
for the PEP - Right before or after initial merging, PEP discussion thread created and linked to in
Discussions-To
andPost-History
Co-authored-by: Guido van Rossum <[email protected]>
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.
LGTM from my side, pending resolution of Guido's final comments. Thanks @JelleZijlstra !
Thanks everyone for the feedback! |
See PEP 702, python/peps#2942.
This is the first time anyone other than me sees this document, so I welcome any feedback.