From 3283b46550ba2d6ee558a244a28c4992c82e42e2 Mon Sep 17 00:00:00 2001 From: jorenham Date: Mon, 7 Apr 2025 22:24:13 +0200 Subject: [PATCH 1/2] TYP: default to `dtype[Any]` --- numpy/__init__.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/__init__.pyi b/numpy/__init__.pyi index f4ae9eed00c2..b2e95a5feccb 100644 --- a/numpy/__init__.pyi +++ b/numpy/__init__.pyi @@ -816,7 +816,7 @@ _2DShapeT_co = TypeVar("_2DShapeT_co", bound=_2D, covariant=True) _1NShapeT = TypeVar("_1NShapeT", bound=tuple[L[1], Unpack[tuple[L[1], ...]]]) # (1,) | (1, 1) | (1, 1, 1) | ... _SCT = TypeVar("_SCT", bound=generic) -_SCT_co = TypeVar("_SCT_co", bound=generic, covariant=True) +_SCT_co = TypeVar("_SCT_co", bound=generic, default=Any, covariant=True) _NumberT = TypeVar("_NumberT", bound=number[Any]) _RealNumberT = TypeVar("_RealNumberT", bound=floating | integer) _FloatingT_co = TypeVar("_FloatingT_co", bound=floating[Any], default=floating[Any], covariant=True) From 4b3a6b42b958b7ca454ccdf5be6b8aaac014ff5d Mon Sep 17 00:00:00 2001 From: jorenham Date: Mon, 7 Apr 2025 22:33:44 +0200 Subject: [PATCH 2/2] DOC: add release note for #28669 --- doc/release/upcoming_changes/28669.new_feature.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 doc/release/upcoming_changes/28669.new_feature.rst diff --git a/doc/release/upcoming_changes/28669.new_feature.rst b/doc/release/upcoming_changes/28669.new_feature.rst new file mode 100644 index 000000000000..2953a5123ccc --- /dev/null +++ b/doc/release/upcoming_changes/28669.new_feature.rst @@ -0,0 +1,3 @@ +* The type parameter of ``np.dtype`` now defaults to ``typing.Any``. + This way, static type-checkers will infer ``dtype: np.dtype`` as + ``dtype: np.dtype[Any]``, without reporting an error.