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) 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: ...