Update docs related to file level error suppression (#8366)

Fixes: #8364

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
doolio 2023-10-31 19:55:43 +01:00 committed by GitHub
parent 43691f97d0
commit 38358980f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -226,14 +226,15 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.
""" # noqa: E501 """ # 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 ```python
# ruff: noqa # ruff: noqa
``` ```
To ignore a specific rule across an entire file, add `# ruff: noqa: {code}` to any line in the file, To ignore a specific rule across an entire file, add the line `# ruff: noqa: {code}` anywhere in the
like so: file, preferably towards the top, like so:
```python ```python
# ruff: noqa: F841 # 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 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. 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 Note that Ruff will also respect Flake8's `# flake8: noqa` directive, and will treat it as
equivalent to `# ruff: noqa`. equivalent to `# ruff: noqa`.

View File

@ -231,8 +231,8 @@ numbers/numbers.py:1:1: D100 Missing docstring in public module
Found 3 errors. 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 If we want to ignore a rule for an entire file, we can add the line `# ruff: noqa: {code}` anywhere
the file: in the file, preferably towards the top, like so:
```py ```py
# ruff: noqa: UP035 # ruff: noqa: UP035