Skip to content

TYP: false positive when using __ge__ between NDArray[np.str_] #28708

@MarcoGorelli

Description

@MarcoGorelli

Describe the issue:

Spotted here: #28689 (comment)

Comparing NPArray[np.str_] using __ge__ erroneously raises when type checking

Reproduce the code example:

import numpy as np
import numpy.typing as npt

def foo(a: npt.NDArray[np.str_]) -> None:
    a > a

Error message:

Operator ">" not supported for types "NDArray[str_]" and "NDArray[str_]" (reportOperatorIssue)

Python and NumPy Versions:

import sys, numpy; print(numpy.version); print(sys.version)

Type-checker version and settings:

$ pyright --version
WARNING: there is a new pyright version available (v1.1.398 -> v1.1.399).
Please install the new version or set PYRIGHT_PYTHON_FORCE_VERSION to latest

pyright 1.1.398

Additional typing packages.

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions