mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
Follow-up with some small doc changes (#3152)
This commit is contained in:
parent
b9bfb81e36
commit
049e77b939
3 changed files with 30 additions and 25 deletions
|
@ -1,7 +1,7 @@
|
|||
Ruff can be configured via a `pyproject.toml` file, a `ruff.toml` file, or through the command line.
|
||||
|
||||
For a complete enumeration of the available configuration options, see the
|
||||
[documentation](/docs/settings/).
|
||||
For a complete enumeration of the available configuration options, see
|
||||
[_Settings_](/docs/settings/).
|
||||
|
||||
### Configure via `pyproject.toml`
|
||||
|
||||
|
@ -109,7 +109,7 @@ If you're wondering how to configure Ruff, here are some **recommended guideline
|
|||
you might consider expanding to `select = ["E", "F", "B"]` to enable the popular flake8-bugbear
|
||||
extension.
|
||||
* By default, Ruff's autofix is aggressive. If you find that it's too aggressive for your liking,
|
||||
consider turning off autofix for specific rules or categories (see: [FAQ](/docs/faq/#ruff-tried-to-fix-something-but-it-broke-my-code-what-should-i-do)).
|
||||
consider turning off autofix for specific rules or categories (see the [_FAQ_](/docs/faq/#ruff-tried-to-fix-something-but-it-broke-my-code-what-should-i-do)).
|
||||
|
||||
### Configure via `ruff.toml`
|
||||
|
||||
|
@ -133,7 +133,8 @@ unfixable = ["B"]
|
|||
"path/to/file.py" = ["E402"]
|
||||
```
|
||||
|
||||
For a full list of configurable options, see the [list of all options](/docs/settings/).
|
||||
For a complete enumeration of the available configuration options, see
|
||||
[_Settings_](/docs/settings/).
|
||||
|
||||
### Command-line interface
|
||||
|
||||
|
@ -313,8 +314,8 @@ For example, `ruff check /path/to/excluded/file.py` will always lint `file.py`.
|
|||
|
||||
### Rule resolution
|
||||
|
||||
The set of enabled rules is controlled via the [`select`](/docs/settings#select)
|
||||
and [`ignore`](/docs/settings#ignore) settings, along with the
|
||||
The set of enabled rules is controlled via the [`select`](/docs/settings#select) and
|
||||
[`ignore`](/docs/settings#ignore) settings, along with the
|
||||
[`extend-select`](/docs/settings#extend-select) and
|
||||
[`extend-ignore`](/docs/settings#extend-ignore) modifiers.
|
||||
|
||||
|
@ -337,8 +338,8 @@ ignore = ["F401"]
|
|||
|
||||
Running `ruff check --select F401` would result in Ruff enforcing `F401`, and no other rules.
|
||||
|
||||
Running `ruff check --extend-select B` would result in Ruff enforcing the `E`, `F`, and `B` rules, with
|
||||
the exception of `F401`.
|
||||
Running `ruff check --extend-select B` would result in Ruff enforcing the `E`, `F`, and `B` rules,
|
||||
with the exception of `F401`.
|
||||
|
||||
### Suppressing errors
|
||||
|
||||
|
@ -346,8 +347,9 @@ To omit a lint rule entirely, add it to the "ignore" list via [`ignore`](/docs/s
|
|||
or [`extend-ignore`](/docs/settings#extend-ignore), either on the command-line
|
||||
or in your `pyproject.toml` file.
|
||||
|
||||
To ignore a violation inline, Ruff uses a `noqa` system similar to [Flake8](https://flake8.pycqa.org/en/3.1.1/user/ignoring-errors.html).
|
||||
To ignore an individual violation, add `# noqa: {code}` to the end of the line, like so:
|
||||
To ignore a violation inline, Ruff uses a `noqa` system similar to
|
||||
[Flake8](https://flake8.pycqa.org/en/3.1.1/user/ignoring-errors.html). To ignore an individual
|
||||
violation, add `# noqa: {code}` to the end of the line, like so:
|
||||
|
||||
```python
|
||||
# Ignore F841.
|
||||
|
@ -394,17 +396,17 @@ equivalent to `# ruff: noqa`.
|
|||
Ruff supports several workflows to aid in `noqa` management.
|
||||
|
||||
First, Ruff provides a special rule code, `RUF100`, to enforce that your `noqa` directives are
|
||||
"valid", in that the violations they _say_ they ignore are actually being triggered on that line (and
|
||||
thus suppressed). You can run `ruff check /path/to/file.py --extend-select RUF100` to flag unused `noqa`
|
||||
directives.
|
||||
"valid", in that the violations they _say_ they ignore are actually being triggered on that line
|
||||
(and thus suppressed). You can run `ruff check /path/to/file.py --extend-select RUF100` to flag
|
||||
unused `noqa` directives.
|
||||
|
||||
Second, Ruff can _automatically remove_ unused `noqa` directives via its autofix functionality.
|
||||
You can run `ruff check /path/to/file.py --extend-select RUF100 --fix` to automatically remove unused
|
||||
`noqa` directives.
|
||||
You can run `ruff check /path/to/file.py --extend-select RUF100 --fix` to automatically remove
|
||||
unused `noqa` directives.
|
||||
|
||||
Third, Ruff can _automatically add_ `noqa` directives to all failing lines. This is useful when
|
||||
migrating a new codebase to Ruff. You can run `ruff check /path/to/file.py --add-noqa` to automatically
|
||||
add `noqa` directives to all failing lines, with the appropriate rule codes.
|
||||
migrating a new codebase to Ruff. You can run `ruff check /path/to/file.py --add-noqa` to
|
||||
automatically add `noqa` directives to all failing lines, with the appropriate rule codes.
|
||||
|
||||
#### Action comments
|
||||
|
||||
|
@ -453,4 +455,3 @@ As an example: to enable autocompletion for Zsh, run
|
|||
fpath+=~/.zfunc
|
||||
autoload -Uz compinit && compinit
|
||||
```
|
||||
|
||||
|
|
|
@ -201,8 +201,8 @@ and in how Ruff and isort treat inline comments in some cases (see: [#1381](http
|
|||
Like isort, Ruff's import sorting is compatible with Black.
|
||||
|
||||
Ruff does not yet support all of isort's configuration options, though it does support many of
|
||||
them. You can find the supported settings in the [API reference](https://beta.ruff.rs/docs/settings/#isort). For example, you can set
|
||||
`known-first-party` like so:
|
||||
them. You can find the supported settings in the [API reference](https://beta.ruff.rs/docs/settings/#isort).
|
||||
For example, you can set `known-first-party` like so:
|
||||
|
||||
```toml
|
||||
[tool.ruff]
|
||||
|
@ -317,8 +317,9 @@ have _complete_ certainty when making changes to code, even for the seemingly tr
|
|||
In the future, Ruff will support enabling autofix behavior based on the safety of the patch.
|
||||
|
||||
In the meantime, if you find that the autofix is too aggressive, you can disable it on a per-rule or
|
||||
per-category basis using the [`unfixable`](https://beta.ruff.rs/docs/settings/#unfixable) mechanic. For example, to disable autofix
|
||||
for some possibly-unsafe rules, you could add the following to your `pyproject.toml`:
|
||||
per-category basis using the [`unfixable`](https://beta.ruff.rs/docs/settings/#unfixable) mechanic.
|
||||
For example, to disable autofix for some possibly-unsafe rules, you could add the following to your
|
||||
`pyproject.toml`:
|
||||
|
||||
```toml
|
||||
[tool.ruff]
|
||||
|
|
|
@ -12,19 +12,22 @@ For **macOS Homebrew** and **Linuxbrew** users, Ruff is also available as [`ruff
|
|||
brew install ruff
|
||||
```
|
||||
|
||||
For **Conda** users, Ruff is also available as [`ruff`](https://anaconda.org/conda-forge/ruff) on `conda-forge`:
|
||||
For **Conda** users, Ruff is also available as [`ruff`](https://anaconda.org/conda-forge/ruff) on
|
||||
`conda-forge`:
|
||||
|
||||
```shell
|
||||
conda install -c conda-forge ruff
|
||||
```
|
||||
|
||||
For **Arch Linux** users, Ruff is also available as [`ruff`](https://archlinux.org/packages/community/x86_64/ruff/) on the official repositories:
|
||||
For **Arch Linux** users, Ruff is also available as [`ruff`](https://archlinux.org/packages/community/x86_64/ruff/)
|
||||
on the official repositories:
|
||||
|
||||
```shell
|
||||
pacman -S ruff
|
||||
```
|
||||
|
||||
For **Alpine** users, Ruff is also available as [`ruff`](https://pkgs.alpinelinux.org/package/edge/testing/x86_64/ruff) on the testing repositories:
|
||||
For **Alpine** users, Ruff is also available as [`ruff`](https://pkgs.alpinelinux.org/package/edge/testing/x86_64/ruff)
|
||||
on the testing repositories:
|
||||
|
||||
```shell
|
||||
apk add ruff
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue