[flake8-bugbear] Fixes a B017 we can actually fix and noqa the two others

This commit is contained in:
Pierre Sassoulas 2024-02-04 11:39:27 +01:00
parent b62d4b3527
commit 41ff3584d7
3 changed files with 3 additions and 4 deletions

View File

@ -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

View File

@ -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)

View File

@ -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")