Skip to content

Types are not hashable (for lru_cache) #4638

Closed
@JelleZijlstra

Description

@JelleZijlstra
$ 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions