From a46827de04b1ab0c0ac20f3ee8302e1221235f19 Mon Sep 17 00:00:00 2001 From: jorenham Date: Wed, 24 Dec 2025 13:50:26 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=91=BD=EF=B8=8F=20`testing`=20depreca?= =?UTF-8?q?tions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/numpy-stubs/testing/_private/utils.pyi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/numpy-stubs/testing/_private/utils.pyi b/src/numpy-stubs/testing/_private/utils.pyi index e352bf9d..dc22aa66 100644 --- a/src/numpy-stubs/testing/_private/utils.pyi +++ b/src/numpy-stubs/testing/_private/utils.pyi @@ -23,7 +23,7 @@ from typing import ( TypeAlias, overload, ) -from typing_extensions import ParamSpec, TypeVar, TypeVarTuple, Unpack +from typing_extensions import ParamSpec, TypeVar, TypeVarTuple, Unpack, deprecated from unittest.case import SkipTest import _numtype as _nt @@ -144,6 +144,7 @@ class clear_and_catch_warnings(warnings.catch_warnings[_W_co], Generic[_W_co]): @overload # record; bool def __init__(self, /, record: bool, modules: _ToModules = ()) -> None: ... +@deprecated("Please use warnings.filterwarnings or pytest.mark.filterwarnings instead") class suppress_warnings: log: Final[_WarnLog] @@ -306,8 +307,10 @@ def assert_array_max_ulp( # @overload +@deprecated("Please use warnings.catch_warnings or pytest.warns instead") def assert_warns(warning_class: _WarningSpec) -> _GeneratorContextManager[None]: ... @overload +@deprecated("Please use warnings.catch_warnings or pytest.warns instead") def assert_warns( warning_class: _WarningSpec, func: Callable[_Tss, _T], *args: _Tss.args, **kwargs: _Tss.kwargs ) -> _T: ... From e87c46341e0739e337cb97bf6167587b2e92d1ac Mon Sep 17 00:00:00 2001 From: jorenham Date: Wed, 24 Dec 2025 14:04:20 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=85=20update=20test=20for=20the=20`te?= =?UTF-8?q?sting.*`=20deprecation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/numpy-stubs/@test/static/accept/testing.pyi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/numpy-stubs/@test/static/accept/testing.pyi b/src/numpy-stubs/@test/static/accept/testing.pyi index c8e102d8..7037db28 100644 --- a/src/numpy-stubs/@test/static/accept/testing.pyi +++ b/src/numpy-stubs/@test/static/accept/testing.pyi @@ -17,7 +17,7 @@ AR_i8: _nt.Array[np.int64] AR_f8: _nt.Array[np.float64] bool_obj: bool -suppress_obj: np.testing.suppress_warnings +suppress_obj: np.testing.suppress_warnings # pyright: ignore[reportDeprecated] func: Callable[[], int] class Test: ... @@ -46,12 +46,12 @@ with np.testing.clear_and_catch_warnings(True) as c1: with np.testing.clear_and_catch_warnings() as c2: assert_type(c2, None) -assert_type(np.testing.suppress_warnings("once"), np.testing.suppress_warnings) -assert_type(np.testing.suppress_warnings()(func), Callable[[], int]) +assert_type(np.testing.suppress_warnings("once"), np.testing.suppress_warnings) # pyright: ignore[reportDeprecated] +assert_type(np.testing.suppress_warnings()(func), Callable[[], int]) # pyright: ignore[reportDeprecated] assert_type(suppress_obj.filter(RuntimeWarning), None) assert_type(suppress_obj.record(RuntimeWarning), list[warnings.WarningMessage]) with suppress_obj as c3: - assert_type(c3, np.testing.suppress_warnings) + assert_type(c3, np.testing.suppress_warnings) # pyright: ignore[reportDeprecated] assert_type(np.testing.verbose, int) assert_type(np.testing.IS_PYPY, bool) @@ -142,8 +142,8 @@ assert_type(np.testing.assert_array_almost_equal_nulp(AR_i8, AR_f8, nulp=2), Non assert_type(np.testing.assert_array_max_ulp(AR_i8, AR_f8, maxulp=2), _nt.Array[np.floating]) assert_type(np.testing.assert_array_max_ulp(AR_i8, AR_f8, dtype=np.float32), _nt.Array[np.floating]) -assert_type(np.testing.assert_warns(RuntimeWarning), contextlib._GeneratorContextManager[None]) -assert_type(np.testing.assert_warns(RuntimeWarning, func3, 5), bool) +assert_type(np.testing.assert_warns(RuntimeWarning), contextlib._GeneratorContextManager[None]) # pyright: ignore[reportDeprecated] +assert_type(np.testing.assert_warns(RuntimeWarning, func3, 5), bool) # pyright: ignore[reportDeprecated] assert_type(np.testing.assert_no_warnings(), contextlib._GeneratorContextManager[None]) assert_type(np.testing.assert_no_warnings(func3, 5), bool)