From 6379138a6da6ebf73bfc4bc4e019a21d8a99be0a Mon Sep 17 00:00:00 2001 From: Aaron Meurer Date: Fri, 9 Jul 2021 14:00:34 -0600 Subject: Rename numpy/_array_api/_types.py to numpy/_array_api/_typing.py --- numpy/_array_api/__init__.py | 2 +- numpy/_array_api/_array_object.py | 2 +- numpy/_array_api/_creation_functions.py | 2 +- numpy/_array_api/_data_type_functions.py | 2 +- numpy/_array_api/_searching_functions.py | 2 +- numpy/_array_api/_set_functions.py | 2 +- numpy/_array_api/_statistical_functions.py | 2 +- numpy/_array_api/_types.py | 26 -------------------------- numpy/_array_api/_typing.py | 26 ++++++++++++++++++++++++++ numpy/_array_api/_utility_functions.py | 2 +- 10 files changed, 34 insertions(+), 34 deletions(-) delete mode 100644 numpy/_array_api/_types.py create mode 100644 numpy/_array_api/_typing.py (limited to 'numpy/_array_api') diff --git a/numpy/_array_api/__init__.py b/numpy/_array_api/__init__.py index be8345759..57a4ff4e1 100644 --- a/numpy/_array_api/__init__.py +++ b/numpy/_array_api/__init__.py @@ -84,7 +84,7 @@ request. argument of an operation is a 0-d array. - All functions include type annotations, corresponding to those given in the - spec (see _types.py for definitions of some custom types). These do not + spec (see _typing.py for definitions of some custom types). These do not currently fully pass mypy due to some limitations in mypy. - Dtype objects are just the NumPy dtype objects, e.g., float64 = diff --git a/numpy/_array_api/_array_object.py b/numpy/_array_api/_array_object.py index 404a09654..2377bffe3 100644 --- a/numpy/_array_api/_array_object.py +++ b/numpy/_array_api/_array_object.py @@ -22,7 +22,7 @@ from ._dtypes import _boolean_dtypes, _integer_dtypes, _floating_dtypes from typing import TYPE_CHECKING if TYPE_CHECKING: - from ._types import Any, Optional, PyCapsule, Tuple, Union, Device, Dtype + from ._typing import Any, Optional, PyCapsule, Tuple, Union, Device, Dtype import numpy as np diff --git a/numpy/_array_api/_creation_functions.py b/numpy/_array_api/_creation_functions.py index 517c2bfdd..88b3808b4 100644 --- a/numpy/_array_api/_creation_functions.py +++ b/numpy/_array_api/_creation_functions.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import TYPE_CHECKING, List, Optional, Tuple, Union if TYPE_CHECKING: - from ._types import (NestedSequence, SupportsDLPack, + from ._typing import (NestedSequence, SupportsDLPack, SupportsBufferProtocol, Array, Device, Dtype) from collections.abc import Sequence from ._dtypes import _all_dtypes diff --git a/numpy/_array_api/_data_type_functions.py b/numpy/_array_api/_data_type_functions.py index 693ceae84..0c42386b5 100644 --- a/numpy/_array_api/_data_type_functions.py +++ b/numpy/_array_api/_data_type_functions.py @@ -5,7 +5,7 @@ from ._array_object import Array from dataclasses import dataclass from typing import TYPE_CHECKING if TYPE_CHECKING: - from ._types import List, Tuple, Union, Dtype + from ._typing import List, Tuple, Union, Dtype from collections.abc import Sequence import numpy as np diff --git a/numpy/_array_api/_searching_functions.py b/numpy/_array_api/_searching_functions.py index 727f3013f..c96f258bb 100644 --- a/numpy/_array_api/_searching_functions.py +++ b/numpy/_array_api/_searching_functions.py @@ -4,7 +4,7 @@ from ._array_object import Array from typing import TYPE_CHECKING if TYPE_CHECKING: - from ._types import Tuple + from ._typing import Tuple import numpy as np diff --git a/numpy/_array_api/_set_functions.py b/numpy/_array_api/_set_functions.py index 098145866..40d4895bf 100644 --- a/numpy/_array_api/_set_functions.py +++ b/numpy/_array_api/_set_functions.py @@ -4,7 +4,7 @@ from ._array_object import Array from typing import TYPE_CHECKING if TYPE_CHECKING: - from ._types import Tuple, Union + from ._typing import Tuple, Union import numpy as np diff --git a/numpy/_array_api/_statistical_functions.py b/numpy/_array_api/_statistical_functions.py index 4f6b1c034..9e032adf0 100644 --- a/numpy/_array_api/_statistical_functions.py +++ b/numpy/_array_api/_statistical_functions.py @@ -4,7 +4,7 @@ from ._array_object import Array from typing import TYPE_CHECKING if TYPE_CHECKING: - from ._types import Optional, Tuple, Union + from ._typing import Optional, Tuple, Union import numpy as np diff --git a/numpy/_array_api/_types.py b/numpy/_array_api/_types.py deleted file mode 100644 index 4ff718205..000000000 --- a/numpy/_array_api/_types.py +++ /dev/null @@ -1,26 +0,0 @@ -""" -This file defines the types for type annotations. - -These names aren't part of the module namespace, but they are used in the -annotations in the function signatures. The functions in the module are only -valid for inputs that match the given type annotations. -""" - -__all__ = ['Array', 'Device', 'Dtype', 'SupportsDLPack', - 'SupportsBufferProtocol', 'PyCapsule'] - -from typing import Any, Sequence, Type, Union - -from . import (Array, int8, int16, int32, int64, uint8, uint16, uint32, - uint64, float32, float64) - -# This should really be recursive, but that isn't supported yet. See the -# similar comment in numpy/typing/_array_like.py -NestedSequence = Sequence[Sequence[Any]] - -Device = Any -Dtype = Type[Union[[int8, int16, int32, int64, uint8, uint16, - uint32, uint64, float32, float64]]] -SupportsDLPack = Any -SupportsBufferProtocol = Any -PyCapsule = Any diff --git a/numpy/_array_api/_typing.py b/numpy/_array_api/_typing.py new file mode 100644 index 000000000..4ff718205 --- /dev/null +++ b/numpy/_array_api/_typing.py @@ -0,0 +1,26 @@ +""" +This file defines the types for type annotations. + +These names aren't part of the module namespace, but they are used in the +annotations in the function signatures. The functions in the module are only +valid for inputs that match the given type annotations. +""" + +__all__ = ['Array', 'Device', 'Dtype', 'SupportsDLPack', + 'SupportsBufferProtocol', 'PyCapsule'] + +from typing import Any, Sequence, Type, Union + +from . import (Array, int8, int16, int32, int64, uint8, uint16, uint32, + uint64, float32, float64) + +# This should really be recursive, but that isn't supported yet. See the +# similar comment in numpy/typing/_array_like.py +NestedSequence = Sequence[Sequence[Any]] + +Device = Any +Dtype = Type[Union[[int8, int16, int32, int64, uint8, uint16, + uint32, uint64, float32, float64]]] +SupportsDLPack = Any +SupportsBufferProtocol = Any +PyCapsule = Any diff --git a/numpy/_array_api/_utility_functions.py b/numpy/_array_api/_utility_functions.py index ba77d3668..3a387877e 100644 --- a/numpy/_array_api/_utility_functions.py +++ b/numpy/_array_api/_utility_functions.py @@ -4,7 +4,7 @@ from ._array_object import Array from typing import TYPE_CHECKING if TYPE_CHECKING: - from ._types import Optional, Tuple, Union + from ._typing import Optional, Tuple, Union import numpy as np -- cgit v1.2.1