diff options
| author | Matti Picus <matti.picus@gmail.com> | 2022-05-21 23:18:46 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-21 23:18:46 +0300 |
| commit | bcdecb33bace9695ed32c8abec8582739159fba2 (patch) | |
| tree | 97fbcb5ac91b7363896f90a73cac4007cd529d90 | |
| parent | 2ada30dd4883649f7a9dd24ccfed750c2095c52e (diff) | |
| parent | 7c98e8c18c147bcbf6f9344376ca380a5d8f6c7b (diff) | |
| download | numpy-bcdecb33bace9695ed32c8abec8582739159fba2.tar.gz | |
Merge pull request #21543 from BvB93/alias
TST,TYP: Fix a python 3.11 failure for the `GenericAlias` tests
| -rw-r--r-- | numpy/typing/tests/test_generic_alias.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/numpy/typing/tests/test_generic_alias.py b/numpy/typing/tests/test_generic_alias.py index 52d3deae4..ae55ef439 100644 --- a/numpy/typing/tests/test_generic_alias.py +++ b/numpy/typing/tests/test_generic_alias.py @@ -17,14 +17,18 @@ T2 = TypeVar("T2") DType = _GenericAlias(np.dtype, (ScalarType,)) NDArray = _GenericAlias(np.ndarray, (Any, DType)) +# NOTE: The `npt._GenericAlias` *class* isn't quite stable on python >=3.11. +# This is not a problem during runtime (as it's 3.8-exclusive), but we still +# need it for the >=3.9 in order to verify its semantics match +# `types.GenericAlias` replacement. xref numpy/numpy#21526 if sys.version_info >= (3, 9): DType_ref = types.GenericAlias(np.dtype, (ScalarType,)) NDArray_ref = types.GenericAlias(np.ndarray, (Any, DType_ref)) - FuncType = Callable[[Union[_GenericAlias, types.GenericAlias]], Any] + FuncType = Callable[["_GenericAlias | types.GenericAlias"], Any] else: DType_ref = Any NDArray_ref = Any - FuncType = Callable[[_GenericAlias], Any] + FuncType = Callable[["_GenericAlias"], Any] GETATTR_NAMES = sorted(set(dir(np.ndarray)) - _GenericAlias._ATTR_EXCEPTIONS) |
