Skip to content

TYP: inconsistent static typing of float64 addition #28071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tyralla opened this issue Dec 27, 2024 · 0 comments · Fixed by #28108
Closed

TYP: inconsistent static typing of float64 addition #28071

tyralla opened this issue Dec 27, 2024 · 0 comments · Fixed by #28108

Comments

@tyralla
Copy link

tyralla commented Dec 27, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants