Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: NDArray[Any] methods ignore overload ambiguity #20099

Closed
@vnmabus

Description

@vnmabus

Describe the issue:

A operation between a NDArray[Any] array and an integer, as in the code example, makes Mypy infer the result as
numpy.ndarray[Any, numpy.dtype[numpy.signedinteger[Any]]]. This is an error, as the result could also be a floating point array, or even a complex one.

Reproduce the code example:

from numpy.typing import NDArray

def f(arr: NDArray[Any]) -> None:
    reveal_type(arr + 2)

Error message:

No response

NumPy/Python version information:

1.21.2 3.7.6 (default, Jan 8 2020, 19:59:22)
[GCC 7.3.0]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions