diff --git a/docs/linter.md b/docs/linter.md index 98546538a5..1f3e4f22b5 100644 --- a/docs/linter.md +++ b/docs/linter.md @@ -337,6 +337,27 @@ violations on a single line. Note that Ruff will also respect Flake8's `# flake8: noqa` directive, and will treat it as equivalent to `# ruff: noqa`. +### Full suppression comment specification + +The full specification is as follows: + +- An inline blanket `noqa` comment is given by a case-insensitive match for + `#noqa` with optional whitespace after the `#` symbol, followed by either: the + end of the comment, the beginning of a new comment (`#`), or whitespace + followed by any character other than `:`. +- An inline rule suppression is given by first finding a case-insensitive match + for `#noqa` with optional whitespace after the `#` symbol, optional whitespace + after `noqa`, and followed by the symbol `:`. After this we are expected to + have a list of rule codes which is given by sequences of uppercase ASCII + characters followed by ASCII digits, separated by whitespace or commas. The + list ends at the last valid code. We will attempt to interpret rules with a + missing delimiter (e.g. `F401F841`), though a warning will be emitted in this + case. +- A file-level exemption comment is given by a case-sensitive match for `#ruff:` + or `#flake8:`, with optional whitespace after `#` and before `:`, followed by + optional whitespace and a case-insensitive match for `noqa`. After this, the + specification is as in the inline case. + ### Detecting unused suppression comments Ruff implements a special rule, [`unused-noqa`](https://docs.astral.sh/ruff/rules/unused-noqa/),