diff --git a/.gitignore b/.gitignore index 0f19c2d..f23c4ae 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ __pycache__ numpy_stubs.egg-info/ venv -.idea \ No newline at end of file +.idea +**~ diff --git a/numpy-stubs/__init__.pyi b/numpy-stubs/__init__.pyi index cb61b7a..0847317 100644 --- a/numpy-stubs/__init__.pyi +++ b/numpy-stubs/__init__.pyi @@ -297,8 +297,6 @@ class ndarray(_ArrayOrScalarCommon, Iterable, Sized, Container): ) -> ndarray: ... @property def dtype(self) -> _Dtype: ... - @dtype.setter - def dtype(self, value: _DtypeLike): ... @property def ctypes(self) -> _ctypes: ... @property diff --git a/tests/fail/ndarray.py b/tests/fail/ndarray.py new file mode 100644 index 0000000..5a5130d --- /dev/null +++ b/tests/fail/ndarray.py @@ -0,0 +1,11 @@ +import numpy as np + +# Ban setting dtype since mutating the type of the array in place +# makes having ndarray be generic over dtype impossible. Generally +# users should use `ndarray.view` in this situation anyway. See +# +# https://github.com/numpy/numpy-stubs/issues/7 +# +# for more context. +float_array = np.array([1.0]) +float_array.dtype = np.bool_ # E: Property "dtype" defined in "ndarray" is read-only