diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2021-05-28 14:11:55 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-28 14:11:55 -0600 |
commit | 336cda183332006ce57750af6b14642a79e3b3f4 (patch) | |
tree | a83a909b421e771b97c9332289a1e975efc079cc /numpy/core/_internal.pyi | |
parent | ca2880476f2f0f9ff3ba4ca0889ac9911727be9b (diff) | |
parent | f5a5fdb345d3d9be90b2bc6832dc6bd0fe66aa5d (diff) | |
download | numpy-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/core/_internal.pyi')
-rw-r--r-- | numpy/core/_internal.pyi | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/numpy/core/_internal.pyi b/numpy/core/_internal.pyi index 1ef1c9fa1..f4bfd770f 100644 --- a/numpy/core/_internal.pyi +++ b/numpy/core/_internal.pyi @@ -2,6 +2,7 @@ from typing import Any, TypeVar, Type, overload, Optional, Generic import ctypes as ct from numpy import ndarray +from numpy.ctypeslib import c_intp _CastT = TypeVar("_CastT", bound=ct._CanCastTo) # Copied from `ctypes.cast` _CT = TypeVar("_CT", bound=ct._CData) @@ -15,18 +16,12 @@ class _ctypes(Generic[_PT]): def __new__(cls, array: ndarray[Any, Any], ptr: None = ...) -> _ctypes[None]: ... @overload def __new__(cls, array: ndarray[Any, Any], ptr: _PT) -> _ctypes[_PT]: ... - - # NOTE: In practice `shape` and `strides` return one of the concrete - # platform dependant array-types (`c_int`, `c_long` or `c_longlong`) - # corresponding to C's `int_ptr_t`, as determined by `_getintp_ctype` - # TODO: Hook this in to the mypy plugin so that a more appropiate - # `ctypes._SimpleCData[int]` sub-type can be returned @property def data(self) -> _PT: ... @property - def shape(self) -> ct.Array[ct.c_int64]: ... + def shape(self) -> ct.Array[c_intp]: ... @property - def strides(self) -> ct.Array[ct.c_int64]: ... + def strides(self) -> ct.Array[c_intp]: ... @property def _as_parameter_(self) -> ct.c_void_p: ... |