Skip to content

Commit

Permalink
TYP: change type annotation for __array_namespace__ to ModuleType
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rgommers authored and asi1024 committed Feb 21, 2022
1 parent 1428e84 commit 28f82b7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cupy/array_api/_array_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
)

from typing import TYPE_CHECKING, Optional, Tuple, Union, Any
import types

if TYPE_CHECKING:
from ._typing import Any, PyCapsule, Device, Dtype
Expand Down Expand Up @@ -419,7 +420,7 @@ def __and__(self: Array, other: Union[int, bool, Array], /) -> Array:

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

0 comments on commit 28f82b7

Please sign in to comment.