Skip to content
Discussion options

You must be logged in to vote

It's important to recognise that mypy has no knowledge of the runtime implementations of anything in the standard library (this is because most of the standard library doesn't have type annotations). The same goes for most other static type checkers.

For the standard library, all mypy knows about is the stubs that are provided for these classes in typeshed. You'll find the definition for Hashable in typeshed here, and you'll find that it's completely different to the implementation at runtime. This is why simply copying the runtime implementation produces code that mypy cannot understand — if you copy the implementation in typeshed instead, you should find that mypy is perfectly able to u…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@geryogam
Comment options

@JelleZijlstra
Comment options

@geryogam
Comment options

Comment options

You must be logged in to vote
2 replies
@geryogam
Comment options

@AlexWaygood
Comment options

Answer selected by geryogam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants