Skip to content

TYP: inconsistent static typing of float64 addition #28071

Closed

Description

@tyralla

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.

Activity

  1. changed the title [-]BUG: inconsistent static typing of float[/-] [+]TYP: inconsistent static typing of `float64` addition[/+] on Dec 27, 2024
  2. added this to the 2.2.2 release milestone on Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions