@@ -292,8 +292,12 @@ see the [`lint.per-file-ignores`](settings.md#lint_per-file-ignores) setting.
292292
293293### Comments
294294
295- Ruff supports multiple forms of suppression comments, including inline and file-level ` noqa `
296- comments, and range suppressions.
295+ Ruff supports multiple forms of suppression comments, including inline and file-level ` noqa ` and
296+ ` ruff: ignore ` comments, and range suppressions.
297+
298+ In [ ` preview ` ] ( preview.md ) mode, rule names (e.g. ` unused-import ` ) can be used in ` ruff: ignore ` ,
299+ ` ruff: file-ignore ` , ` ruff: disable ` , and ` ruff: enable ` comments instead of rule codes (e.g.
300+ ` F401 ` ).
297301
298302#### Line-level
299303
@@ -344,20 +348,18 @@ The full inline comment specification is as follows:
344348 missing delimiter (e.g. ` F401F841 ` ), though a warning will be emitted in this
345349 case.
346350
347- * The following is currently only available in [ preview mode] ( `preview.md` ) .*
348-
349351To cover an entire "logical" line (a multi-line statement or suite header),
350352an "ignore" comment may be placed above the first line:
351353
352354``` python
353- # ruff: ignore[unused-function-argument ] # Covers the entire function signature
355+ # ruff: ignore[ARG001 ] # Covers the entire function signature
354356def foo (
355357 arg1 ,
356358 arg2 ,
357359):
358360 pass
359361
360- # ruff: ignore[line-too-long ] # Covers the entire list literal
362+ # ruff: ignore[E501 ] # Covers the entire list literal
361363things = [
362364 " really long string literal ..." ,
363365 " really long string literal ..." ,
@@ -371,13 +373,13 @@ of the multi-line statement or header uncovered:
371373``` python
372374def foo (
373375 arg1 ,
374- # ruff: ignore[unused-function-argument ] # Only covers `arg2`
376+ # ruff: ignore[ARG001 ] # Only covers `arg2`
375377 arg2 ,
376378):
377379 pass
378380
379381things = [
380- " really long string literal ..." , # ruff: ignore[line-too-long ] # Only covers this line
382+ " really long string literal ..." , # ruff: ignore[E501 ] # Only covers this line
381383 " really long string literal ..." ,
382384]
383385```
@@ -386,8 +388,8 @@ Ignore comments can also be "stacked" with other comments or pragmas, and will
386388still cover the next logical line:
387389
388390``` python
389- # ruff: ignore[ambiguous-variable-name ]
390- # ruff: ignore[unused-variable ]
391+ # ruff: ignore[E741 ]
392+ # ruff: ignore[F841 ]
391393# I definitely know what I'm doing.
392394i = 1
393395```
@@ -454,9 +456,6 @@ be used to terminate a preceding "disable" comment with identical codes.
454456Unlike ` noqa ` suppressions, range suppressions do not support "blanket" suppression
455457of all violations. At least one violation code must be listed.
456458
457- In [ ` preview ` ] ( preview.md ) mode, rule names (e.g. ` unused-import ` ) can be used in these comments
458- instead of rule codes (e.g. ` F401 ` ).
459-
460459The full range suppression comment specification is as follows:
461460
462461- An own-line comment starting with case sensitive ` #ruff: ` , with optional whitespace
@@ -496,12 +495,11 @@ The file-level suppression comment specification is as follows:
496495 optional whitespace and a case-insensitive match for ` noqa ` . After this, the
497496 specification is as in the inline ` noqa ` suppressions above.
498497
499- In [ ` preview ` ] ( preview.md ) mode, one or more rules can be ignored across an
500- entire file with a ` file-ignore ` comment on its own line, at global module scope,
501- and preferably near the top of the file:
498+ One or more rules can also be ignored across an entire file with a ` file-ignore ` comment on its own
499+ line, at global module scope, and preferably near the top of the file:
502500
503501``` python
504- # ruff: file-ignore[unused-import, unused-function-argument ]
502+ # ruff: file-ignore[F401, ARG001 ]
505503```
506504
507505The full-level suppression comment specification is as follows:
@@ -534,15 +532,17 @@ $ ruff check /path/to/file.py --extend-select RUF100 --fix
534532### Inserting necessary suppression comments
535533
536534Ruff can _ automatically add_ suppression comments to all lines that contain violations, which is
537- useful when migrating a new codebase to Ruff. To add the appropriate comments to all relevant
538- lines, run Ruff with ` --add-noqa ` :
535+ useful when migrating a new codebase to Ruff. To add the appropriate comments to all relevant lines,
536+ run Ruff with ` --add-noqa ` to add ` noqa ` comments or with ` --add-ignore ` to add ` ruff: ignore `
537+ comments:
539538
540539``` shell-session
541540$ ruff check /path/to/file.py --add-noqa
541+ $ ruff check /path/to/file.py --add-ignore
542542```
543543
544- The ` --add-noqa ` flag adds ` noqa ` directives with rule codes. To add ` ruff: ignore ` comments with
545- human-readable rule names instead, use ` --add-ignore ` with preview mode enabled.
544+ Both of these flags use rule codes on stable . To add ` ruff: ignore ` comments with human-readable
545+ rule names instead, use ` --add-ignore ` with preview mode enabled.
546546
547547### isort action comments
548548
0 commit comments