8000 Merge pull request #21543 from BvB93/alias · numpy/numpy@bcdecb3 · GitHub
[go: up one dir, main page]

Skip to content

Commit bcdecb3

Browse files
authored
Merge pull request #21543 from BvB93/alias
TST,TYP: Fix a python 3.11 failure for the `GenericAlias` tests
2 parents 2ada30d + 7c98e8c commit bcdecb3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

numpy/typing/tests/test_generic_alias.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@
1717
DType = _GenericAlias(np.dtype, (ScalarType,))
1818
NDArray = _GenericAlias(np.ndarray, (Any, DType))
1919

20+
# NOTE: The `npt._GenericAlias` *class* isn't quite stable on python >=3.11.
21+
# This is not a problem during runtime (as it's 3.8-exclusive), but we still
22+
# need it for the >=3.9 in order to verify its semantics match
23+
# `types.GenericAlias` replacement. xref numpy/numpy#21526
2024
if sys.version_info >= (3, 9):
2125
DType_ref = types.GenericAlias(np.dtype, (ScalarType,))
2226
NDArray_ref = types.GenericAlias(np.ndarray, (Any, DType_ref))
23-
FuncType = Callable[[Union[_GenericAlias, types.GenericAlias]], Any]
27+
FuncType = Callable[["_GenericAlias | types.GenericAlias"], Any]
2428
else:
2529
DType_ref = Any
2630
NDArray_ref = Any
27-
FuncType = Callable[[_GenericAlias], Any]
31+
FuncType = Callable[["_GenericAlias"], Any]
2832

2933
GETATTR_NAMES = sorted(set(dir(np.ndarray)) - _GenericAlias._ATTR_EXCEPTIONS)
3034

0 commit comments

Comments
 (0)
0