Repository navigation
Deprecate typing.Hashable/Sized #94309
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement
on Jun 26, 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.
Are they just for convenience?
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
I agree that we should be consistent.
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.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.Reacted by Alex Waygood and MonadChains@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 incollections.abc - Build the documentation with either
make htmlor./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!).
Reacted by Alex Waygood and MonadChains- added a commit that references this issue
on Jul 6, 2022 - added a commit that references this issue
on Jul 10, 2022 Fixed in #94626. Thanks @MonadChains! 🎉
Reacted by MonadChainsReopening as per #94626 (comment)
Reopening as per #94626 (comment)
I've opened a new pull request to add the missing part.
Reacted by Hugo van Kemenade- added a commit that references this issue
on Jul 14, 2022 - added a commit that references this issue
on Nov 17, 2023 - added a commit that references this issue
on Nov 17, 2023 - added a commit that references this issue
on Feb 11, 2024
typing.Hashableandtyping.Sizedare aliases to their equivalents in thecollections.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
Linked PRs