-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
TYP: [2.4.0rc1 regression] np.generic no longer Hashable #30445
Copy link
Copy link
Closed
Description
Describe the issue:
The code below passes without error when using numpy 2.3.5, but gives the error message below on 2.4.0rc1.
cc @alexfikl
Reproduce the code example:
from typing import Hashable
import numpy as np
def f(x: np.generic) -> Hashable:
return xError message:
/home/andreas/tmp/tnumpy.py:7:12 - error: Type "generic[Any]" is not assignable to return type "Hashable"
"generic[Any]" is incompatible with protocol "Hashable"
"__hash__" is an incompatible type
"__hash__" is not defined as a ClassVar in protocol
Type "None" is not assignable to type "() -> int" (reportReturnType)
1 error, 0 warnings, 0 notesPython and NumPy Versions:
Python 3.14.2
Type-checker version and settings:
basedpyright 1.36.1
based on pyright 1.1.407
no settings applied
Additional typing packages.
No response
Reactions are currently unavailable