Enable lint PGH004 - Use specific rule codes when using noqa
This commit is contained in:
parent
d1ee6d154f
commit
a182e10b06
|
@ -5,7 +5,7 @@ if __name__ == "__main__":
|
|||
import cProfile
|
||||
import pstats
|
||||
|
||||
import pytest # NOQA
|
||||
import pytest # noqa: F401
|
||||
|
||||
script = sys.argv[1:] if len(sys.argv) > 1 else ["empty.py"]
|
||||
cProfile.run("pytest.cmdline.main(%r)" % script, "prof")
|
||||
|
|
|
@ -172,7 +172,7 @@ class TestRaises:
|
|||
raise ValueError("demo error")
|
||||
|
||||
def test_tupleerror(self):
|
||||
a, b = [1] # NOQA
|
||||
a, b = [1] # noqa: F841
|
||||
|
||||
def test_reinterpret_fails_with_print_for_the_fun_of_it(self):
|
||||
items = [1, 2, 3]
|
||||
|
@ -180,7 +180,7 @@ class TestRaises:
|
|||
a, b = items.pop()
|
||||
|
||||
def test_some_error(self):
|
||||
if namenotexi: # NOQA
|
||||
if namenotexi: # noqa: F821
|
||||
pass
|
||||
|
||||
def func1(self):
|
||||
|
|
|
@ -103,6 +103,7 @@ select = [
|
|||
"RUF", # ruff
|
||||
"W", # pycodestyle
|
||||
"PIE", # flake8-pie
|
||||
"PGH004", # pygrep-hooks - Use specific rule codes when using noqa
|
||||
]
|
||||
ignore = [
|
||||
# bugbear ignore
|
||||
|
|
|
@ -1006,7 +1006,7 @@ class AssertionRewriter(ast.NodeVisitor):
|
|||
if i:
|
||||
fail_inner: List[ast.stmt] = []
|
||||
# cond is set in a prior loop iteration below
|
||||
self.expl_stmts.append(ast.If(cond, fail_inner, [])) # noqa
|
||||
self.expl_stmts.append(ast.If(cond, fail_inner, [])) # noqa: F821
|
||||
self.expl_stmts = fail_inner
|
||||
# Check if the left operand is a ast.NamedExpr and the value has already been visited
|
||||
if (
|
||||
|
|
|
@ -712,7 +712,7 @@ class TestRequestBasic:
|
|||
)
|
||||
def test_request_garbage(self, pytester: Pytester) -> None:
|
||||
try:
|
||||
import xdist # noqa
|
||||
import xdist # noqa: F401
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
|
|
|
@ -200,7 +200,7 @@ class TestAssertionRewrite:
|
|||
assert getmsg(f2) == "assert False"
|
||||
|
||||
def f3() -> None:
|
||||
assert a_global # type: ignore[name-defined] # noqa
|
||||
assert a_global # type: ignore[name-defined] # noqa: F821
|
||||
|
||||
assert getmsg(f3, {"a_global": False}) == "assert False"
|
||||
|
||||
|
|
|
@ -535,7 +535,7 @@ class TestSession:
|
|||
newid = item.nodeid
|
||||
assert newid == id
|
||||
pprint.pprint(hookrec.calls)
|
||||
topdir = pytester.path # noqa
|
||||
topdir = pytester.path # noqa: F841
|
||||
hookrec.assert_contains(
|
||||
[
|
||||
("pytest_collectstart", "collector.path == topdir"),
|
||||
|
|
|
@ -794,7 +794,7 @@ def test_resource_warning(pytester: Pytester, monkeypatch: pytest.MonkeyPatch) -
|
|||
# available, using `importorskip("tracemalloc")` for example,
|
||||
# because we want to ensure the same code path does not break in those platforms.
|
||||
try:
|
||||
import tracemalloc # noqa
|
||||
import tracemalloc # noqa: F401
|
||||
|
||||
has_tracemalloc = True
|
||||
except ImportError:
|
||||
|
|
Loading…
Reference in New Issue