Skip to content

Deprecate typing.Hashable/Sized #94309

Description

@Numerlor

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

Linked PRs

Activity

  1. Fidget-Spinner commented on Jun 27, 2022

    @Fidget-Spinner
    Member

    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.

  2. AlexWaygood commented on Jun 27, 2022

    @AlexWaygood
    Member

    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

  3. gvanrossum commented on Jun 27, 2022

    @gvanrossum
    Member

    I agree that we should be consistent.

  4. MonadChains commented on Jul 5, 2022

    @MonadChains
    Contributor

    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.

  5. JelleZijlstra commented on Jul 5, 2022

    @JelleZijlstra
    Member

    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.

  6. Fidget-Spinner commented on Jul 6, 2022

    @Fidget-Spinner
    Member

    @MonadChains thanks for your interest in contributing. Here's what you have to do after cloning cpython.

    1. Go to /Doc/library/typing.rst.
    2. 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
    3. Build the documentation with either make html or ./Doc/make.bat html. View the html output in ./Doc/build/.
    4. 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!).
  7. added a commit that references this issue on Jul 6, 2022
  8. added a commit that references this issue on Jul 10, 2022
  9. AlexWaygood commented on Jul 10, 2022

    @AlexWaygood
    Member

    Fixed in #94626. Thanks @MonadChains! 🎉

  10. AlexWaygood commented on Jul 10, 2022

    @AlexWaygood
    Member

    Reopening as per #94626 (comment)

  11. MonadChains commented on Jul 10, 2022

    @MonadChains
    Contributor

    Reopening as per #94626 (comment)

    I've opened a new pull request to add the missing part.

  12. added a commit that references this issue on Jul 14, 2022
  13. added 2 commits that reference this issue on Nov 17, 2023
  14. added a commit that references this issue on Nov 17, 2023
  15. added a commit that references this issue on Nov 17, 2023
  16. added a commit that references this issue on Nov 17, 2023
  17. added a commit that references this issue on Feb 11, 2024
  18. added a commit that references this issue on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions