diff --git a/docs/linter.md b/docs/linter.md index d73c9bb1b0104..6c94ac3e57b50 100644 --- a/docs/linter.md +++ b/docs/linter.md @@ -226,14 +226,15 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor. """ # noqa: E501 ``` -To ignore all violations across an entire file, add `# ruff: noqa` to any line in the file, like so: +To ignore all violations across an entire file, add the line `# ruff: noqa` anywhere in the file, +preferably towards the top, like so: ```python # ruff: noqa ``` -To ignore a specific rule across an entire file, add `# ruff: noqa: {code}` to any line in the file, -like so: +To ignore a specific rule across an entire file, add the line `# ruff: noqa: {code}` anywhere in the +file, preferably towards the top, like so: ```python # ruff: noqa: F841 @@ -242,6 +243,9 @@ like so: Or see the [`per-file-ignores`](settings.md#per-file-ignores) setting, which enables the same functionality from within your `pyproject.toml` or `ruff.toml` file. +Global `noqa` comments must be on their own line to disambiguate from comments which ignore +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`. diff --git a/docs/tutorial.md b/docs/tutorial.md index 54eff737dc280..d986e5b737489 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -231,8 +231,8 @@ numbers/numbers.py:1:1: D100 Missing docstring in public module Found 3 errors. ``` -If we want to ignore a rule for an entire file, we can add a `# ruff: noqa` comment to the top of -the file: +If we want to ignore a rule for an entire file, we can add the line `# ruff: noqa: {code}` anywhere +in the file, preferably towards the top, like so: ```py # ruff: noqa: UP035