summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2021-03-11 14:30:01 +0100
committerRalf Gommers <ralf.gommers@gmail.com>2021-03-12 16:56:31 +0100
commit335b6cb399ecaa869cf78c49984eb1dcc412b8bc (patch)
tree48fb8fa0476033a146ca3b329967553dbe0afdc8
parentf75336e55c10ebcacf55aec5505fd8c0b93ba81a (diff)
downloadnumpy-335b6cb399ecaa869cf78c49984eb1dcc412b8bc.tar.gz
MAINT: Relax the signature of the `__array__` protocol
Implementations of `__array__` do not require the `dtype` parameter
-rw-r--r--numpy/typing/_array_like.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/numpy/typing/_array_like.py b/numpy/typing/_array_like.py
index ef6c061d1..eb8d3f4e1 100644
--- a/numpy/typing/_array_like.py
+++ b/numpy/typing/_array_like.py
@@ -40,11 +40,12 @@ _DType_co = TypeVar("_DType_co", covariant=True, bound="dtype[Any]")
if TYPE_CHECKING or HAVE_PROTOCOL:
# The `_SupportsArray` protocol only cares about the default dtype
- # (i.e. `dtype=None`) of the to-be returned array.
+ # (i.e. `dtype=None` or no `dtype` parameter at all) of the to-be returned
+ # array.
# Concrete implementations of the protocol are responsible for adding
# any and all remaining overloads
class _SupportsArray(Protocol[_DType_co]):
- def __array__(self, dtype: None = ...) -> ndarray[Any, _DType_co]: ...
+ def __array__(self) -> ndarray[Any, _DType_co]: ...
else:
_SupportsArray = Any