Skip to content

Commit 716e7f3

Browse files
committed
move section up, minor tweaks to wording
1 parent 38e9923 commit 716e7f3

1 file changed

Lines changed: 21 additions & 20 deletions

File tree

docs/linter.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,27 @@ violations on a single line.
337337
Note that Ruff will also respect Flake8's `# flake8: noqa` directive, and will treat it as
338338
equivalent to `# ruff: noqa`.
339339

340+
### Full suppression comment specification
341+
342+
The full specification is as follows:
343+
344+
- An inline blanket `noqa` comment is given by a case-insensitive match for
345+
`#noqa` with optional whitespace after the `#` symbol, followed by either: the
346+
end of the comment, the beginning of a new comment (`#`), or whitespace
347+
followed by any character other than `:`.
348+
- An inline rule suppression is given by first finding a case-insensitive match
349+
for `#noqa` with optional whitespace after the `#` symbol, optional whitespace
350+
after `noqa`, and followed by the symbol `:`. After this we are expected to
351+
have a list of rule codes which is given by sequences of uppercase ASCII
352+
characters followed by ASCII digits, separated by whitespace or commas. The
353+
list ends at the last valid code. We will attempt to interpret rules with a
354+
missing delimiter (e.g. `F401F841`), though a warning will be emitted in this
355+
case.
356+
- A file-level exemption comment is given by a case-sensitive match for `#ruff:`
357+
or `#flake8:`, with optional whitespace after `#` and before `:`, followed by
358+
optional whitespace and a case-insensitive match for `noqa`. After this, the
359+
specification is as in the inline case.
360+
340361
### Detecting unused suppression comments
341362

342363
Ruff implements a special rule, [`unused-noqa`](https://docs.astral.sh/ruff/rules/unused-noqa/),
@@ -353,26 +374,6 @@ Ruff can _automatically add_ `noqa` directives to all lines that contain violati
353374
useful when migrating a new codebase to Ruff. To automatically add `noqa` directives to all
354375
relevant lines (with the appropriate rule codes), run: `ruff check /path/to/file.py --add-noqa`.
355376

356-
### Full suppression comment specification
357-
358-
The full specification is as follows:
359-
360-
- An inline blanket `noqa` comment is given by a case-insensitive match for
361-
`#noqa` with optional whitespace after the `#` symbol, followed by either: the
362-
end of the comment, the beginning of a new comment (`#`), or whitespace
363-
followed by any character other than `:`.
364-
- An inline rule suppression is given by first finding a case-insensitive match
365-
for `#noqa` with optional whitespace after the `#` symbol, optional whitespace
366-
after noqa, and followed by the symbol `:`. After this we are expected to have
367-
a list of rule codes which is given by sequences of uppercase ascii characters
368-
followed by ascii digits, separated by whitespace or commas. The list ends at
369-
the last valid code. We will attempt to interpret rules with a missing
370-
delimiter (e.g. `F401F841`), though a warning will be emitted in this case.
371-
- A file-level exemption comment is given by a case-sensitive match for `#ruff:`
372-
or `#flake8:`, with optional whitespace after `#` and before `:`, followed by
373-
optional whitespace and a case-insensitive match for `noqa`. After this, the
374-
specification is as in the inline case.
375-
376377
### Action comments
377378

378379
Ruff respects isort's [action comments](https://pycqa.github.io/isort/docs/configuration/action_comments.html)

0 commit comments

Comments
 (0)