summaryrefslogtreecommitdiff
path: root/numpy/typing/tests
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2021-05-28 14:11:55 -0600
committerGitHub <noreply@github.com>2021-05-28 14:11:55 -0600
commit336cda183332006ce57750af6b14642a79e3b3f4 (patch)
treea83a909b421e771b97c9332289a1e975efc079cc /numpy/typing/tests
parentca2880476f2f0f9ff3ba4ca0889ac9911727be9b (diff)
parentf5a5fdb345d3d9be90b2bc6832dc6bd0fe66aa5d (diff)
downloadnumpy-336cda183332006ce57750af6b14642a79e3b3f4.tar.gz
Merge pull request #19062 from BvB93/ctypes-plugin
ENH: Add a mypy plugin for inferring the precision of `np.ctypeslib.c_intp`
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}"
}