You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typing.Hashable and typing.Sized are aliases to their equivalents in the collections.abc module; PEP 585 deprecated all aliases like these while aiming to remove the duplication between the two modules, but the aforementioned two seem to have been left out of that because they're not generic.
If the others are deprecated, I don't think it makes sense to keep them when they're just aliases that provide no additional functionality
I'm +1 for deprecating them too. Before that, I'm interested as to why we have these aliases in typing? Are they just for convenience? Searching commit history, I think @gvanrossum might have an idea.
According to PEP 484: yup! For both Sized and Hashable, PEP 484 states that they are "not generic, but present [in the proposed new typing module] for completeness": https://peps.python.org/pep-0484/#the-typing-module
Hi, I'm new to the Python codebase, and I would like to contribute to it. I have a question about this issue: what is the deprecation procedure for the aliases? According to PEP 585, the deprecated aliases should not trigger any DeprecationWarning and only type checkers should warn of their usage. So I'm not sure what are exactly the changes needed.
I think we should just add a deprecation notice in the docs, similar to that for typing.Iterable and similar. We don't need any runtime behavior change.
@MonadChains thanks for your interest in contributing. Here's what you have to do after cloning cpython.
Go to /Doc/library/typing.rst.
Copy one of the .. deprecated:: notices and paste it under the appropriate sections those types. Edit the text saying to use the type in collections.abc
Build the documentation with either make html or ./Doc/make.bat html. View the html output in ./Doc/build/.
The file uses reStructuredText for documentation. I suggest reading this guide as there may be surprising things to beginners (such as indents using 3 spaces instead of 4!).
Activity
Fidget-Spinner commentedon Jun 27, 2022
I'm +1 for deprecating them too. Before that, I'm interested as to why we have these aliases in typing? Are they just for convenience? Searching commit history, I think @gvanrossum might have an idea.
AlexWaygood commentedon Jun 27, 2022
According to PEP 484: yup! For both Sized and Hashable, PEP 484 states that they are "not generic, but present [in the proposed new typing module] for completeness": https://peps.python.org/pep-0484/#the-typing-module
gvanrossum commentedon Jun 27, 2022
I agree that we should be consistent.
MonadChains commentedon Jul 5, 2022
Hi, I'm new to the Python codebase, and I would like to contribute to it. I have a question about this issue: what is the deprecation procedure for the aliases? According to PEP 585, the deprecated aliases should not trigger any
DeprecationWarningand only type checkers should warn of their usage. So I'm not sure what are exactly the changes needed.JelleZijlstra commentedon Jul 5, 2022
I think we should just add a deprecation notice in the docs, similar to that for
typing.Iterableand similar. We don't need any runtime behavior change.Fidget-Spinner commentedon Jul 6, 2022
@MonadChains thanks for your interest in contributing. Here's what you have to do after cloning cpython.
.. deprecated::notices and paste it under the appropriate sections those types. Edit the text saying to use the type incollections.abcmake htmlor./Doc/make.bat html. View the html output in./Doc/build/.pythongh-94309: Deprecate typing.Hashable/Sized
gh-94309: Deprecate typing.Hashable/Sized (GH-94626)
AlexWaygood commentedon Jul 10, 2022
Fixed in #94626. Thanks @MonadChains! 🎉
AlexWaygood commentedon Jul 10, 2022
Reopening as per #94626 (comment)
MonadChains commentedon Jul 10, 2022
I've opened a new pull request to add the missing part.
gh-94309: Add typing.Hashable and typing.Sized for "What's New for Py…
pythongh-94309: Fix documentation for deprecated aliases
pythongh-94309: Fix documentation for deprecated aliases
gh-94309: "What's new in Python 3.12": improve deprecation notice for…
pythongh-94309: "What's new in Python 3.12": improve deprecation noti…
[3.12] gh-94309: "What's new in Python 3.12": improve deprecation not…
pythongh-94309: "What's new in Python 3.12": improve deprecation noti…
pythongh-94309: "What's new in Python 3.12": improve deprecation noti…