summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-11-22 14:15:31 +0100
committerBas van Beek <b.f.van.beek@vu.nl>2021-11-22 14:40:15 +0100
commit99fee43fbf7e696fb86b7f5ddee64caeea0bda0d (patch)
tree50fd82762fb40c764f3430167e0cc81a374172e6
parent0e9b464df4720028ef8739bf75ce5a44137a0bb7 (diff)
downloadnumpy-99fee43fbf7e696fb86b7f5ddee64caeea0bda0d.tar.gz
BUG: Fix an incorrect protocol used in `np.lib.shape_base`
-rw-r--r--numpy/lib/shape_base.pyi4
-rw-r--r--numpy/typing/tests/data/fail/shape_base.pyi8
2 files changed, 10 insertions, 2 deletions
diff --git a/numpy/lib/shape_base.pyi b/numpy/lib/shape_base.pyi
index 8aa283d02..17016c999 100644
--- a/numpy/lib/shape_base.pyi
+++ b/numpy/lib/shape_base.pyi
@@ -18,7 +18,7 @@ from numpy.typing import (
NDArray,
_ShapeLike,
_FiniteNestedSequence,
- _SupportsDType,
+ _SupportsArray,
_ArrayLikeBool_co,
_ArrayLikeUInt_co,
_ArrayLikeInt_co,
@@ -31,7 +31,7 @@ from numpy.core.shape_base import vstack
_SCT = TypeVar("_SCT", bound=generic)
-_ArrayLike = _FiniteNestedSequence[_SupportsDType[dtype[_SCT]]]
+_ArrayLike = _FiniteNestedSequence[_SupportsArray[dtype[_SCT]]]
# The signatures of `__array_wrap__` and `__array_prepare__` are the same;
# give them unique names for the sake of clarity
diff --git a/numpy/typing/tests/data/fail/shape_base.pyi b/numpy/typing/tests/data/fail/shape_base.pyi
new file mode 100644
index 000000000..e709741b7
--- /dev/null
+++ b/numpy/typing/tests/data/fail/shape_base.pyi
@@ -0,0 +1,8 @@
+import numpy as np
+
+class DTypeLike:
+ dtype: np.dtype[np.int_]
+
+dtype_like: DTypeLike
+
+np.expand_dims(dtype_like, (5, 10)) # E: No overload variant