mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
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:
parent
43691f97d0
commit
38358980f1
2 changed files with 9 additions and 5 deletions
|
@ -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`.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue