Skip to content

Commit 4a45d24

Browse files
rgommerscharris
authored andcommitted
TYP: change type annotation for __array_namespace__ to ModuleType
This is more precise, we are returning a module here. Type checkers will be able to use this info in the future - see data-apis/array-api#267
1 parent f9d73fe commit 4a45d24

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

numpy/array_api/_array_object.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
)
3131

3232
from typing import TYPE_CHECKING, Optional, Tuple, Union, Any
33+
import types
3334

3435
if TYPE_CHECKING:
3536
from ._typing import Any, PyCapsule, Device, Dtype
@@ -415,7 +416,7 @@ def __and__(self: Array, other: Union[int, bool, Array], /) -> Array:
415416

416417
def __array_namespace__(
417418
self: Array, /, *, api_version: Optional[str] = None
418-
) -> Any:
419+
) -> types.ModuleType:
419420
if api_version is not None and not api_version.startswith("2021."):
420421
raise ValueError(f"Unrecognized array API version: {api_version!r}")
421422
return array_api

0 commit comments

Comments
 (0)