Skip to content

Commit acf35c5

Browse files
authored
Add new noqa specification to the docs (#16703)
## Summary Adds @dylwil3's new `noqa` specification to the linter `Error suppression` page instead of the release blog post. Originally taken from his PR comment [here](#16483 (comment)). ## Test Plan None
1 parent b9b2562 commit acf35c5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/linter.md

Lines changed: 21 additions & 0 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/),

0 commit comments

Comments
 (0)