You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some c++ - python compatible features and use ctypes lib for creating dtypes dynamically.
np.dtype typing is incorrect when ctypes type is argument.
Reproducing code example:
# myproblem.pyimportctypesfromtypingimportTYPE_CHECKINGimportnumpyasnpdtype_int=np.dtype(ctypes.c_int)
dtype_size_t=np.dtype(ctypes.c_size_t)
print(repr(dtype_int)) # prints `dtype('int32')>` as expected on my machineprint(repr(dtype_size_t)) # prints `dtype('uint64')` as expected on my machineifTYPE_CHECKING:
reveal_type(dtype_int) # something like `numpy.dtype[numpy.signedinteger[numpy.typing._32Bit]]` is expectedreveal_type(dtype_size_t) # something like `numpy.dtype[numpy.unsignedinteger[numpy.typing._64Bit]]` is expected
Mypy error message:
$ mypy test.py
myproblem.py:8: error: Value of type variable "_DTypeScalar_co" of "dtype" cannot be "c_int"
myproblem.py:9: error: Value of type variable "_DTypeScalar_co" of "dtype" cannot be "c_size_t"
myproblem.py:13: note: Revealed type is "numpy.dtype[ctypes.c_int*]"
myproblem.py:14: note: Revealed type is "numpy.dtype[ctypes.c_size_t*]"
Found 2 errors in 1 file (checked 1 source file)
I have some c++ - python compatible features and use ctypes lib for creating dtypes dynamically.
np.dtype typing is incorrect when ctypes type is argument.
Reproducing code example:
Mypy error message:
NumPy/Python version information:
The text was updated successfully, but these errors were encountered: