-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Description
Describe the issue:
Pyright (and python) infer np.dtype (and other sub-classes of np._ArrayOrScalarCommon) as not Hashable as they overwrite __eq__ without overwriting __hash__.
Reproduce the code example:
from typing import Hashable
import numpy as np
def test(x: Hashable) -> None: ...
def foo() -> np.dtype: ...
test(foo())Error message:
error: Argument of type "dtype[Unknown]" cannot be assigned to parameter "x" of type "Hashable" in function "test"
"dtype[Unknown]" is incompatible with protocol "Hashable"
"__hash__" is an incompatible type
Type "None" cannot be assigned to type "(self: dtype[Unknown]) -> int" (reportGeneralTypeIssues)Runtime information:
>>> import sys, numpy; print(numpy.__version__); print(sys.version)
1.24.4
3.11.4 (main, Jun 14 2023, 18:15:32) [GCC 12.2.0]
>>> print(numpy.show_runtime())
WARNING: `threadpoolctl` not found in system! Install it by `pip install threadpoolctl`. Once installed, try `np.show_runtime` again for more detailed build information
[{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_KNL',
'AVX512_KNM',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL']}}]
NoneContext for the issue:
No response