Skip to content

Commit

Permalink
Update docs related to file level error suppression (#8366)
Browse files Browse the repository at this point in the history
Fixes: #8364

---------

Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
  • Loading branch information
doolio and charliermarsh authored Oct 31, 2023
1 parent 43691f9 commit 3835898
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions docs/linter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`.

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3835898

Please sign in to comment.