diff options
author | Matti Picus <matti.picus@gmail.com> | 2020-10-19 16:13:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-19 16:13:55 +0300 |
commit | fb27bd593222f42b4dad5286dcb9be4b74f34273 (patch) | |
tree | 81dae180e6558be2e04d589fa774643ee05b7fba | |
parent | 8fadcf13ddbbce596d008e206bf3127cfc379377 (diff) | |
parent | f1b9adb1c794ea36a31bdc304d3f8dc80833c008 (diff) | |
download | numpy-fb27bd593222f42b4dad5286dcb9be4b74f34273.tar.gz |
Merge pull request #17584 from BvB93/type_aliases
ENH: Add annotations for `np.core._type_aliases`
-rw-r--r-- | numpy/__init__.pyi | 7 | ||||
-rw-r--r-- | numpy/core/_type_aliases.pyi | 19 | ||||
-rw-r--r-- | numpy/typing/tests/data/reveal/constants.py | 3 |
3 files changed, 27 insertions, 2 deletions
diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index f70965c41..c62227e5e 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -141,6 +141,11 @@ from numpy.core._asarray import ( require as require, ) +from numpy.core._type_aliases import ( + sctypes as sctypes, + sctypeDict as sctypeDict, +) + from numpy.core.numeric import ( zeros_like as zeros_like, ones as ones, @@ -460,8 +465,6 @@ save: Any savetxt: Any savez: Any savez_compressed: Any -sctypeDict: Any -sctypes: Any select: Any set_printoptions: Any set_string_function: Any diff --git a/numpy/core/_type_aliases.pyi b/numpy/core/_type_aliases.pyi new file mode 100644 index 000000000..6a1099cd3 --- /dev/null +++ b/numpy/core/_type_aliases.pyi @@ -0,0 +1,19 @@ +import sys +from typing import Dict, Union, Type, List + +from numpy import generic, signedinteger, unsignedinteger, floating, complexfloating + +if sys.version_info >= (3, 8): + from typing import TypedDict +else: + from typing_extensions import TypedDict + +class _SCTypes(TypedDict): + int: List[Type[signedinteger]] + uint: List[Type[unsignedinteger]] + float: List[Type[floating]] + complex: List[Type[complexfloating]] + others: List[type] + +sctypeDict: Dict[Union[int, str], Type[generic]] +sctypes: _SCTypes diff --git a/numpy/typing/tests/data/reveal/constants.py b/numpy/typing/tests/data/reveal/constants.py index dc5803974..b2382e861 100644 --- a/numpy/typing/tests/data/reveal/constants.py +++ b/numpy/typing/tests/data/reveal/constants.py @@ -47,3 +47,6 @@ reveal_type(np.True_) # E: numpy.bool_ reveal_type(np.False_) # E: numpy.bool_ reveal_type(np.UFUNC_PYVALS_NAME) # E: str + +reveal_type(np.sctypeDict) # E: dict +reveal_type(np.sctypes) # E: TypedDict |