From eea34e16af8f6277302a3bf1f6886e58786cdf49 Mon Sep 17 00:00:00 2001 From: Bas van Beek <43369155+BvB93@users.noreply.github.com> Date: Thu, 14 Jul 2022 12:44:40 +0200 Subject: [PATCH] MAINT: Do not let `_GenericAlias` wrap the underlying classes `__class__` attribute Adapt to the 3.11b4 changes introduced in https://github.com/python/cpython/pull/93754 --- numpy/_typing/_generic_alias.py | 1 + numpy/typing/tests/test_generic_alias.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/numpy/_typing/_generic_alias.py b/numpy/_typing/_generic_alias.py index d32814a72025..01cd224adbe9 100644 --- a/numpy/_typing/_generic_alias.py +++ b/numpy/_typing/_generic_alias.py @@ -216,6 +216,7 @@ def __iter__(self: _T) -> Generator[_T, None, None]: "__deepcopy__", "__unpacked__", "__typing_unpacked_tuple_args__", + "__class__", }) def __getattribute__(self, name: str) -> Any: diff --git a/numpy/typing/tests/test_generic_alias.py b/numpy/typing/tests/test_generic_alias.py index 093e12109da6..861babd4b3ad 100644 --- a/numpy/typing/tests/test_generic_alias.py +++ b/numpy/typing/tests/test_generic_alias.py @@ -120,9 +120,12 @@ def test_dir(self) -> None: # and they are thus now longer equivalent ("__ne__", lambda n: n != next(iter(n)), ("beta", 1)), - # >= beta3 stuff + # >= beta3 ("__typing_unpacked_tuple_args__", lambda n: n.__typing_unpacked_tuple_args__, ("beta", 3)), + + # >= beta4 + ("__class__", lambda n: n.__class__ == type(n), ("beta", 4)), ]) def test_py311_features( self,