summaryrefslogtreecommitdiff
path: root/numpy/typing/tests
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-05-21 20:40:42 +0200
committerBas van Beek <b.f.van.beek@vu.nl>2021-05-21 21:15:16 +0200
commit5eca599bccb93edccf9a61de76ddc6125b5a76cf (patch)
treefd81b27671d29455bb3a4f1b88a6e441472eec98 /numpy/typing/tests
parent869243e50c5a607b792d5102bd0ce360c377e8eb (diff)
downloadnumpy-5eca599bccb93edccf9a61de76ddc6125b5a76cf.tar.gz
TST: Add typing tests for `np.ctypeslib.c_intp` and its mypy plugin
Diffstat (limited to 'numpy/typing/tests')
-rw-r--r--numpy/typing/tests/data/reveal/ctypeslib.py3
-rw-r--r--numpy/typing/tests/data/reveal/ndarray_misc.py4
-rw-r--r--numpy/typing/tests/test_typing.py9
3 files changed, 13 insertions, 3 deletions
diff --git a/numpy/typing/tests/data/reveal/ctypeslib.py b/numpy/typing/tests/data/reveal/ctypeslib.py
new file mode 100644
index 000000000..0c32d70ed
--- /dev/null
+++ b/numpy/typing/tests/data/reveal/ctypeslib.py
@@ -0,0 +1,3 @@
+import numpy as np
+
+reveal_type(np.ctypeslib.c_intp()) # E: {c_intp}
diff --git a/numpy/typing/tests/data/reveal/ndarray_misc.py b/numpy/typing/tests/data/reveal/ndarray_misc.py
index ea01b7aa4..2e198eb6f 100644
--- a/numpy/typing/tests/data/reveal/ndarray_misc.py
+++ b/numpy/typing/tests/data/reveal/ndarray_misc.py
@@ -23,8 +23,8 @@ AR_U: np.ndarray[Any, np.dtype[np.str_]]
ctypes_obj = AR_f8.ctypes
reveal_type(ctypes_obj.data) # E: int
-reveal_type(ctypes_obj.shape) # E: ctypes.Array[ctypes.c_int64]
-reveal_type(ctypes_obj.strides) # E: ctypes.Array[ctypes.c_int64]
+reveal_type(ctypes_obj.shape) # E: ctypes.Array[{c_intp}]
+reveal_type(ctypes_obj.strides) # E: ctypes.Array[{c_intp}]
reveal_type(ctypes_obj._as_parameter_) # E: ctypes.c_void_p
reveal_type(ctypes_obj.data_as(ct.c_void_p)) # E: ctypes.c_void_p
diff --git a/numpy/typing/tests/test_typing.py b/numpy/typing/tests/test_typing.py
index be08c1359..35558c880 100644
--- a/numpy/typing/tests/test_typing.py
+++ b/numpy/typing/tests/test_typing.py
@@ -8,7 +8,11 @@ from typing import Optional, IO, Dict, List
import pytest
import numpy as np
-from numpy.typing.mypy_plugin import _PRECISION_DICT, _EXTENDED_PRECISION_LIST
+from numpy.typing.mypy_plugin import (
+ _PRECISION_DICT,
+ _EXTENDED_PRECISION_LIST,
+ _C_INTP,
+)
try:
from mypy import api
@@ -219,6 +223,9 @@ def _construct_format_dict():
# numpy.typing
"_NBitInt": dct['_NBitInt'],
+
+ # numpy.ctypeslib
+ "c_intp": f"ctypes.{_C_INTP}"
}