PyPy 3.9 failing NumPy typing tests
PyPy3.9 is failing the full NumPy test suite. The failing cases are all new for python3.9 and have to do with GenericAlias
:
import types
from typing import TypeVar, Any, Union, Callable
from numpy._typing._generic_alias import _GenericAlias
import numpy as np
DType_ref = types.GenericAlias(np.dtype, (ScalarType,))
NDArray_ref = types.GenericAlias(np.ndarray, (Any, DType_ref))
NDArray = _GenericAlias(np.ndarray, (Any, DType))
setattr(NDArray_ref, "__origin__", int)) # should raise AttributeError
setattr(NDArray_ref, "test", int) # should raise AttributeError
assert dir(NDArray) == dir(NDArray_ref) # do not match: left side is missing `__copy__`, `__deepcopy__`, `__reduce__`, `__reduce_ex__`
assert repr(NDArray) == repr(NDArray_ref) # left: `'numpy.ndarray[typing.Any, numpy.dtype[+ScalarType]]'`, right: `'numpy.ndarray[typing.Any, numpy.dtype]'`