Closed
Description
Describe the bug
None
cannot be assigned to typing.Hashable
. None
is hashable in Python.
To Reproduce
Type check the snippet below.
Expected behavior
That None
would be accepted as a value of type Hashable
.
Screenshots or Code
from typing import Dict, Hashable
# Expression of type "None" cannot be assigned to declared type "Hashable"
# Type "None" cannot be assigned to type "Hashable"
foo: Hashable = None
# Expression of type "dict[None, str]" cannot be assigned to declared type "Dict"
# TypeVar "_KT" is invariant
# Type "None" cannot be assigned to type "Hashable"
bar: Dict[Hashable, str] = {None: ''}
# True
isinstance(None, Hashable)
VS Code extension or command-line
Extension, 1.1.65