diff --git a/pyproject.toml b/pyproject.toml index 89aab6a07..cf6e5adec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -145,7 +145,6 @@ ignore = [ "B009", # Do not call `getattr` with a constant attribute value "B010", # [*] Do not call `setattr` with a constant attribute value. "B011", # Do not `assert False` (`python -O` removes these calls) - "B017", # `pytest.raises(Exception)` should be considered evil "B023", # Function definition does not bind loop variable `warning` "B028", # No explicit `stacklevel` keyword argument found # pycodestyle ignore diff --git a/testing/python/raises.py b/testing/python/raises.py index ef6607d96..929865e31 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -280,7 +280,7 @@ class TestRaises: def test_raises_context_manager_with_kwargs(self): with pytest.raises(TypeError) as excinfo: - with pytest.raises(Exception, foo="bar"): # type: ignore[call-overload] + with pytest.raises(OSError, foo="bar"): # type: ignore[call-overload] pass assert "Unexpected keyword arguments" in str(excinfo.value) diff --git a/testing/test_compat.py b/testing/test_compat.py index 9e66e9eca..c898af7c5 100644 --- a/testing/test_compat.py +++ b/testing/test_compat.py @@ -169,7 +169,7 @@ class ErrorsHelper: def test_helper_failures() -> None: helper = ErrorsHelper() - with pytest.raises(Exception): + with pytest.raises(Exception): # noqa: B017 _ = helper.raise_exception with pytest.raises(OutcomeException): _ = helper.raise_fail_outcome @@ -179,7 +179,7 @@ def test_safe_getattr() -> None: helper = ErrorsHelper() assert safe_getattr(helper, "raise_exception", "default") == "default" assert safe_getattr(helper, "raise_fail_outcome", "default") == "default" - with pytest.raises(BaseException): + with pytest.raises(BaseException): # noqa: B017 assert safe_getattr(helper, "raise_baseexception", "default")