[flake8-bugbear] Fix all the useless expressions that are justified
This commit is contained in:
parent
fcb818b73c
commit
52fba25ff9
|
@ -148,7 +148,6 @@ ignore = [
|
|||
"B011", # Do not `assert False` (`python -O` removes these calls)
|
||||
"B015", # Pointless comparison. Did you mean to assign a value?
|
||||
"B017", # `pytest.raises(Exception)` should be considered evil
|
||||
"B018", # Found useless expression.
|
||||
"B023", # Function definition does not bind loop variable `warning`
|
||||
"B028", # No explicit `stacklevel` keyword argument found
|
||||
# pycodestyle ignore
|
||||
|
|
|
@ -208,7 +208,7 @@ def main() -> None:
|
|||
f.write(f"This list contains {len(plugins)} plugins.\n\n")
|
||||
f.write(".. only:: not latex\n\n")
|
||||
|
||||
wcwidth # reference library that must exist for tabulate to work
|
||||
_ = wcwidth # reference library that must exist for tabulate to work
|
||||
plugin_table = tabulate.tabulate(plugins, headers="keys", tablefmt="rst")
|
||||
f.write(indent(plugin_table, " "))
|
||||
f.write("\n\n")
|
||||
|
|
|
@ -209,8 +209,8 @@ class TestCaseFunction(Function):
|
|||
)
|
||||
# Invoke the attributes to trigger storing the traceback
|
||||
# trial causes some issue there.
|
||||
excinfo.value
|
||||
excinfo.traceback
|
||||
_ = excinfo.value
|
||||
_ = excinfo.traceback
|
||||
except TypeError:
|
||||
try:
|
||||
try:
|
||||
|
|
|
@ -1241,9 +1241,9 @@ class TestWINLocalPath:
|
|||
|
||||
def test_owner_group_not_implemented(self, path1):
|
||||
with pytest.raises(NotImplementedError):
|
||||
path1.stat().owner
|
||||
_ = path1.stat().owner
|
||||
with pytest.raises(NotImplementedError):
|
||||
path1.stat().group
|
||||
_ = path1.stat().group
|
||||
|
||||
def test_chmod_simple_int(self, path1):
|
||||
mode = path1.stat().mode
|
||||
|
|
|
@ -387,7 +387,7 @@ def test_excinfo_no_python_sourcecode(tmp_path: Path) -> None:
|
|||
excinfo = pytest.raises(ValueError, template.render, h=h)
|
||||
for item in excinfo.traceback:
|
||||
print(item) # XXX: for some reason jinja.Template.render is printed in full
|
||||
item.source # shouldn't fail
|
||||
_ = item.source # shouldn't fail
|
||||
if isinstance(item.path, Path) and item.path.name == "test.txt":
|
||||
assert str(item.source) == "{{ h()}}:"
|
||||
|
||||
|
@ -418,7 +418,7 @@ def test_codepath_Queue_example() -> None:
|
|||
|
||||
def test_match_succeeds():
|
||||
with pytest.raises(ZeroDivisionError) as excinfo:
|
||||
0 // 0
|
||||
_ = 0 // 0
|
||||
excinfo.match(r".*zero.*")
|
||||
|
||||
|
||||
|
@ -584,7 +584,7 @@ class TestFormattedExcinfo:
|
|||
try:
|
||||
|
||||
def f():
|
||||
1 / 0
|
||||
_ = 1 / 0
|
||||
|
||||
f()
|
||||
|
||||
|
@ -601,7 +601,7 @@ class TestFormattedExcinfo:
|
|||
print(line)
|
||||
assert lines == [
|
||||
" def f():",
|
||||
"> 1 / 0",
|
||||
"> _ = 1 / 0",
|
||||
"E ZeroDivisionError: division by zero",
|
||||
]
|
||||
|
||||
|
@ -638,7 +638,7 @@ raise ValueError()
|
|||
pr = FormattedExcinfo()
|
||||
|
||||
try:
|
||||
1 / 0
|
||||
_ = 1 / 0
|
||||
except ZeroDivisionError:
|
||||
excinfo = ExceptionInfo.from_current()
|
||||
|
||||
|
@ -1582,7 +1582,7 @@ def test_no_recursion_index_on_recursion_error():
|
|||
return getattr(self, "_" + attr)
|
||||
|
||||
with pytest.raises(RuntimeError) as excinfo:
|
||||
RecursionDepthError().trigger
|
||||
_ = RecursionDepthError().trigger
|
||||
assert "maximum recursion" in str(excinfo.getrepr())
|
||||
|
||||
|
||||
|
|
|
@ -170,9 +170,9 @@ class ErrorsHelper:
|
|||
def test_helper_failures() -> None:
|
||||
helper = ErrorsHelper()
|
||||
with pytest.raises(Exception):
|
||||
helper.raise_exception
|
||||
_ = helper.raise_exception
|
||||
with pytest.raises(OutcomeException):
|
||||
helper.raise_fail_outcome
|
||||
_ = helper.raise_fail_outcome
|
||||
|
||||
|
||||
def test_safe_getattr() -> None:
|
||||
|
|
|
@ -108,7 +108,7 @@ class TestFixtureRequestSessionScoped:
|
|||
AttributeError,
|
||||
match="path not available in session-scoped context",
|
||||
):
|
||||
session_request.fspath
|
||||
_ = session_request.fspath
|
||||
|
||||
|
||||
@pytest.mark.parametrize("config_type", ["ini", "pyproject"])
|
||||
|
|
|
@ -42,7 +42,7 @@ class TestMark:
|
|||
def test_pytest_mark_name_starts_with_underscore(self) -> None:
|
||||
mark = MarkGenerator(_ispytest=True)
|
||||
with pytest.raises(AttributeError):
|
||||
mark._some_name
|
||||
_ = mark._some_name
|
||||
|
||||
|
||||
def test_marked_class_run_twice(pytester: Pytester) -> None:
|
||||
|
|
Loading…
Reference in New Issue