Skip to content

Conversation

@JelleZijlstra
Copy link
Member

Fixes #2148.

I went over the builtins manually and grepped for other classes in the standard library that declare __hash__ = None.

Some interesting things I learned:

  • slice is not hashable, even though it is immutable.
  • In Python 3, decimal.Context is hashable but _pydecimal.Context is not. We don't have a stub for _pydecimal, so I made no changes in typeshed.

@JelleZijlstra JelleZijlstra changed the title mark some types as non-hashable [WIP] mark some types as non-hashable Jun 12, 2018
@gvanrossum
Copy link
Member

So IIUC this requires a mypy change first?

@ilevkivskyi
Copy link
Member

So IIUC this requires a mypy change first?

Yes, see the comment in #2148

@JelleZijlstra
Copy link
Member Author

Filed python/mypy#5217 to fix the mypy issue; I'm going to close this until we fix mypy.

@srittau
Copy link
Collaborator

srittau commented Aug 13, 2019

Reopening per discussion in #2148. @JelleZijlstra

@srittau srittau reopened this Aug 13, 2019
@JelleZijlstra
Copy link
Member Author

The merge conflict looks bad, I won't have time to fix it right now.

srittau added a commit to srittau/typeshed that referenced this pull request Sep 3, 2019
@srittau
Copy link
Collaborator

srittau commented Sep 3, 2019

Closing in favor of #3219, which is based on this PR.

@srittau srittau closed this Sep 3, 2019
@JelleZijlstra JelleZijlstra deleted the nohash branch September 4, 2019 14:58
srittau added a commit that referenced this pull request Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-hashable types should declare __hash__: None in typeshed

4 participants