Closed
Description
Describe the issue:
This is a regression due to changes in Numpy 2.2. The bug is correctly identified both by Mypy and Pyright. The given error message is from Mypy. I initially mentioned this problem in #27957 and was asked by @jorenham to report it separately. See #27957 for more information.
Reproduce the code example:
import numpy
from numpy.typing import NDArray
def f() -> NDArray[numpy.float64]:
return numpy.zeros(2, dtype=numpy.float64) + numpy.float64(1.0)
Error message:
Incompatible return value type (got "ndarray[tuple[int, ...], dtype[floating[Any]]]", expected "ndarray[tuple[int, ...], dtype[float64]]")
Python and NumPy Versions:
Python 3.13.1
Numpy 2.2.1
Runtime Environment:
No response
Context for the issue:
In one of our projects, this regression results in 30 (unhelpful) error messages.