diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index 4feaa3bbb..4b61db496 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -84,7 +84,7 @@ def deprecated_call( @overload def warns( - expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]], + expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]] = ..., *, match: Optional[Union[str, Pattern[str]]] = ..., ) -> "WarningsChecker": diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index 027a773b8..479f1f26d 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -188,5 +188,5 @@ def test_warns_none_is_deprecated(): "Replace pytest.warns(None) by simply pytest.warns()." ), ): - with pytest.warns(None): + with pytest.warns(None): # type: ignore[call-overload] pass diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py index 963f3aef2..40a2e23fa 100644 --- a/testing/test_recwarn.py +++ b/testing/test_recwarn.py @@ -310,7 +310,7 @@ class TestWarns: # This should become an error when WARNS_NONE_ARG is removed in Pytest 7.0 with warnings.catch_warnings(): warnings.simplefilter("ignore") - with pytest.warns(None) as record: + with pytest.warns(None) as record: # type: ignore[call-overload] warnings.warn("user", UserWarning) warnings.warn("runtime", RuntimeWarning) diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py index fe4b8b8cd..4dff9dff0 100644 --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -403,7 +403,7 @@ class TestRmRf: # ignored function with warnings.catch_warnings(): warnings.simplefilter("ignore") - with pytest.warns(None) as warninfo: + with pytest.warns(None) as warninfo: # type: ignore[call-overload] exc_info4 = (None, PermissionError(), None) on_rm_rf_error(os.open, str(fn), exc_info4, start_path=tmp_path) assert fn.is_file()