Skip to content

Commit bc47a5b

Browse files
authored
Merge pull request #23150 from charris/backport-23144
TYP, MAINT: Add a missing explicit ``Any`` parameter to the ``npt.ArrayLike`` definition
2 parents 2433fe5 + e5452b9 commit bc47a5b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Diff for: numpy/_typing/_array_like.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# NOTE: Import `Sequence` from `typing` as we it is needed for a type-alias,
44
# not an annotation
5+
import sys
56
from collections.abc import Collection, Callable
67
from typing import Any, Sequence, Protocol, Union, TypeVar, runtime_checkable
78
from numpy import (
@@ -82,10 +83,16 @@ def __array_function__(
8283
# is resolved. See also the mypy issue:
8384
#
8485
# https://github.com/python/typing/issues/593
85-
ArrayLike = _DualArrayLike[
86-
dtype,
87-
Union[bool, int, float, complex, str, bytes],
88-
]
86+
if sys.version_info[:2] < (3, 9):
87+
ArrayLike = _DualArrayLike[
88+
dtype,
89+
Union[bool, int, float, complex, str, bytes],
90+
]
91+
else:
92+
ArrayLike = _DualArrayLike[
93+
dtype[Any],
94+
Union[bool, int, float, complex, str, bytes],
95+
]
8996

9097
# `ArrayLike<X>_co`: array-like objects that can be coerced into `X`
9198
# given the casting rules `same_kind`

0 commit comments

Comments
 (0)