Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types are not hashable (for lru_cache) #4638

Closed
JelleZijlstra opened this issue Oct 9, 2020 · 2 comments
Closed

Types are not hashable (for lru_cache) #4638

JelleZijlstra opened this issue Oct 9, 2020 · 2 comments

Comments

@JelleZijlstra
Copy link
Member

$ cat tmp/typesort.py 
from typing import Type
from functools import lru_cache


class A:
    pass


@lru_cache()
def f(x: Type[A]) -> None:
    pass


x: Type[A]
f(x)
$ mypy tmp/typesort.py 
tmp/typesort.py:15: error: Argument 1 to "__call__" of "_lru_cache_wrapper" has incompatible type "Type[A]"; expected "Hashable"
Found 1 error in 1 file (checked 1 source file)

This is a regression in mypy 0.790, but I haven't figured out whether it's due to changes in typeshed or mypy. I'm hoping it's fixable in typeshed. Interestingly mypy allows {x} (a set with x in it).

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Oct 9, 2020

mypy_primer also bisected this one to python/mypy#8965. Assuming this means it comes from #3944

@JelleZijlstra
Copy link
Member Author

This is python/mypy#11469 and python/mypy#11470.

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

No branches or pull requests

2 participants