Skip to content

Commit 4b7ae75

Browse files
committed
TYP: Fix typing errors in ndarray builtin type conversion operators
1 parent 583e431 commit 4b7ae75

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

numpy/__init__.pyi

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,22 +2241,10 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeType_co, _DType_co]):
22412241
offset: SupportsIndex = ...
22422242
) -> NDArray[Any]: ...
22432243

2244-
# Dispatch to the underlying `generic` via protocols
2245-
def __int__(
2246-
self: NDArray[SupportsInt], # type: ignore[type-var]
2247-
) -> int: ...
2248-
2249-
def __float__(
2250-
self: NDArray[SupportsFloat], # type: ignore[type-var]
2251-
) -> float: ...
2252-
2253-
def __complex__(
2254-
self: NDArray[SupportsComplex], # type: ignore[type-var]
2255-
) -> complex: ...
2256-
2257-
def __index__(
2258-
self: NDArray[SupportsIndex], # type: ignore[type-var]
2259-
) -> int: ...
2244+
def __index__(self: NDArray[np.integer[Any]], /) -> int: ...
2245+
def __int__(self: NDArray[number[Any] | np.bool | object_], /) -> int: ...
2246+
def __float__(self: NDArray[number[Any] | np.bool | object_], /) -> float: ...
2247+
def __complex__(self: NDArray[number[Any] | np.bool | object_], /) -> complex: ...
22602248

22612249
def __len__(self) -> int: ...
22622250
def __setitem__(self, key, value): ...

0 commit comments

Comments
 (0)