Skip to content

Commit a652441

Browse files
authored
Merge pull request #198 from jakkdl/ruff
use ruff noqa handling
2 parents 6f3ee3b + 7780a13 commit a652441

File tree

7 files changed

+17
-18
lines changed

7 files changed

+17
-18
lines changed

flake8_trio/visitors/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def iter_guaranteed_once(iterable: ast.expr) -> bool:
146146
):
147147
try:
148148
values = [ast.literal_eval(a) for a in iterable.args]
149-
except Exception: # noqa: PIE786
149+
except Exception:
150150
# parameters aren't literal
151151
return False
152152

flake8_trio/visitors/visitor103_104.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def visit_For(self, node: ast.For | ast.While):
177177
if isinstance(node, ast.While):
178178
try:
179179
infinite_loop = body_guaranteed_once = bool(ast.literal_eval(node.test))
180-
except Exception: # noqa: PIE786
180+
except Exception:
181181
body_guaranteed_once = False
182182
self.visit_nodes(node.test)
183183
else:

flake8_trio/visitors/visitor91x.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def leave_FunctionDef(
307307
updated_node = updated_node.with_changes(body=indentedblock)
308308

309309
self.restore_state(original_node)
310-
return updated_node # noqa: R504
310+
return updated_node
311311

312312
# error if function exit/return/yields with uncheckpointed statements
313313
# returns a bool indicating if any real (i.e. not artificial) errors were raised
@@ -686,7 +686,7 @@ def leave_While(
686686

687687
self.restore_state(original_node)
688688
# https://github.com/afonasev/flake8-return/issues/133
689-
return updated_node # noqa: R504
689+
return updated_node
690690

691691
leave_For = leave_While
692692

flake8_trio/visitors/visitor_utility.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,14 @@ def visit_Import(self, node: cst.Import):
147147
# https://github.com/PyCQA/flake8/blob/d016204366a22d382b5b56dc14b6cbff28ce929e/src/flake8/defaults.py#L27
148148
NOQA_INLINE_REGEXP = re.compile(
149149
# We're looking for items that look like this:
150-
# ``# noqa``
151-
# ``# noqa: E123``
152-
# ``# noqa: E123,W451,F921``
153-
# ``# noqa:E123,W451,F921``
154-
# ``# NoQA: E123,W451,F921``
155-
# ``# NOQA: E123,W451,F921``
156-
# ``# NOQA:E123,W451,F921``
150+
# ``# nxqa``
151+
# ``# nxqa: E123``
152+
# ``# nxqa: E123,W451,F921``
153+
# ``# nxqa:E123,W451,F921``
154+
# ``# NxQA: E123,W451,F921``
155+
# ``# NXQA: E123,W451,F921``
156+
# ``# NXQA:E123,W451,F921``
157+
# (o/O replaced with x/X to avoid the wrath of flake8-noqa/RUF100)
157158
# We do not want to capture the ``: `` that follows ``noqa``
158159
# We do not care about the casing of ``noqa``
159160
# We want a comma-separated list of errors

pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ ignore = [
8787
'TD003', # missing issue link in TODO
8888
'TRY003', # Avoid specifying long messages outside the exception class
8989
'TRY200', # Use `raise from` to specify exception cause
90-
'TRY201', # Use `raise` without specifying exception name
91-
# enable if flake8/plugins are removed
92-
'PGH004', # Use specific rule codes when using `noqa`
93-
'RUF100' # Unused `noqa` - enable only if flake8 is no longer used
90+
'TRY201' # Use `raise` without specifying exception name
9491
]
9592
line-length = 90
9693
select = ["ALL"]

tests/test_config_and_args.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_systemexit_0(
6969
tmp_path.joinpath("example.py").write_text("")
7070

7171
with pytest.raises(SystemExit) as exc_info:
72-
from flake8_trio import __main__ # noqa
72+
from flake8_trio import __main__ # noqa: F401
7373

7474
assert exc_info.value.code == 0
7575
out, err = capsys.readouterr()
@@ -84,7 +84,7 @@ def test_systemexit_1(
8484
monkeypatch_argv(monkeypatch, tmp_path)
8585

8686
with pytest.raises(SystemExit) as exc_info:
87-
from flake8_trio import __main__ # noqa
87+
from flake8_trio import __main__ # noqa: F401
8888

8989
assert exc_info.value.code == 1
9090
out, err = capsys.readouterr()

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ exclude_lines =
4848

4949
[flake8]
5050
max-line-length = 90
51-
extend-ignore = S101, D101, D102, D103, D105, D106, D107
51+
# not supported by ruff + want to `noqa` them, so instead ignoring them: PIE786, R504
52+
extend-ignore = S101, D101, D102, D103, D105, D106, D107, PIE786, R504
5253
extend-enable = TC10
5354
exclude = .*, tests/eval_files/*, tests/autofix_files/*
5455
per-file-ignores =

0 commit comments

Comments
 (0)