You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to annotate a dict of supported hashing algorithms.
fromtypingimportCallable, Optional, Dictimporthashlibfrom_hashlibimportHASH#: Hash algorithm, as returned by hashlib.new()HashAlgorithm=Callable[[Optional[bytes]], HASH]
ALGORITHMS= {
'md5': hashlib.md5,
'sha1': hashlib.sha1,
'sha224': hashlib.sha224,
'sha256': hashlib.sha256,
'sha384': hashlib.sha384,
'sha512': hashlib.sha512
} # type: Dict[str, HashAlgorithm]
This is resulting in a weird / confusing error message (ignore line numbers).
file.py823: error: Dict entry 0 has incompatible type "str": "Callable[[Union[bytes, bytearray, memoryview]], _Hash]"; expected "str": "Callable[[Optional[bytes]], Any]"
file.py:823: error: Dict entry 1 has incompatible type "str": "Callable[[Union[bytes, bytearray, memoryview]], _Hash]"; expected "str": "Callable[[Optional[bytes]], Any]"
# same error for each entry in the dict
Switching the value type to just Callbable fixes the issue, but it seems to me that there's an underlying problem here.
Version info:
python -V
python 3.7.3
mypy -V
mypy 0.720
The text was updated successfully, but these errors were encountered:
I'm trying to annotate a
dict
of supported hashing algorithms.This is resulting in a weird / confusing error message (ignore line numbers).
Switching the value type to just
Callbable
fixes the issue, but it seems to me that there's an underlying problem here.Version info:
The text was updated successfully, but these errors were encountered: