-
Notifications
You must be signed in to change notification settings - Fork 140
Closed
astral-sh/ruff
#21553Description
Summary
When using np.isclose, ty infers the result as bool[bool], causing it to report that the result is not iterable.
MRE
from typing import reveal_type
import numpy as np
import numpy.typing as npt
x: npt.NDArray[np.bool_] = np.isclose([1e10, 1e-7], [1.00001e10, 1e-8])
reveal_type(x)
for val in x:
print(val)ty
$ uvx --with numpy==2.2.6 ty check dev/ty.py
WARN ty is pre-release software and not ready for production use. Expect to encounter bugs, missing features, and fatal errors.
info[revealed-type]: Revealed type
--> dev\ty.py:8:13
|
6 | x: npt.NDArray[np.bool_] = np.isclose([1e10, 1e-7], [1.00001e10, 1e-8])
7 |
8 | reveal_type(x)
| ^ `bool[bool]`
9 |
10 | for val in x:
|
error[not-iterable]: Object of type `bool[bool]` is not iterable
--> dev\ty.py:10:12
|
8 | reveal_type(x)
9 |
10 | for val in x:
| ^
11 | print(val)
|
info: It doesn't have an `__iter__` method or a `__getitem__` method
info: rule `not-iterable` is enabled by default
Found 2 diagnostics
mypy
$ uvx --with numpy==2.2.6 mypy dev/ty.py
dev\ty.py:8: note: Revealed type is "numpy.ndarray[builtins.tuple[builtins.int, ...], numpy.dtype[numpy.bool[builtins.bool]]]"
Success: no issues found in 1 source file
Version
ty 0.0.1-alpha.8 (c1337c9 2025-06-02)
Metadata
Metadata
Assignees
Labels
No labels