A Visual Studio Code extension with support for the Ruff linter. Available on the Visual Studio Marketplace.
The extension ships with ruff==0.0.192.
(Interested in using Ruff with another editor? Check out
ruff-lsp.)
Once installed in Visual Studio Code, ruff will automatically execute when you open or edit a
Python file.
If you want to disable Ruff, you can disable this extension per workspace in Visual Studio Code.
| Settings | Default | Description |
|---|---|---|
| args | [] |
Custom arguments passed to ruff. E.g "args": ["--config=/path/to/pyproject.toml"]. |
| logLevel | error |
Sets the tracing level for the extension. |
| path | [] |
Setting to provide custom ruff executables, to try in order. E.g. ["/path/to/ruff"]. |
| interpreter | [] |
Path to a Python interpreter to use to run the linter server. |
| showNotification | off |
Setting to control when a notification is shown. |
| organizeImports | true |
Whether to register Ruff as capable of handling source.organizeImports actions. |
| fixAll | true |
Whether to register Ruff as capable of handling source.fixAll actions. |
You can configure Ruff to autofix violations on-save by enabling the source.fixAll action in
settings.json:
{
"[python]": {
"editor.codeActionsOnSave": {
"source.fixAll": true
}
}
}You can configure Ruff to organize imports on-save by enabling the source.organizeImports action in
settings.json:
{
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
}
}If you're using the VS Code Python extension, you can configure VS Code to autofix violations
on-save using Ruff, then re-format with Black, via the following settings.json:
{
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
}
},
"python.formatting.provider": "black"
}If you'd like to use Ruff as an autofix linter, but continue to sort imports with the isort VS
Code extension, you can disable Ruff's import-sorting capabilities via the following
settings.json:
{
"[python]": {
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
}
},
"ruff.organizeImports": false
}If you'd like to run Ruff on-save, but avoid enabling other extensions to run on-save, you can
use Ruff's scoped source.fixAll and source.organizeImports actions via the following settings.json:
{
"[python]": {
"editor.codeActionsOnSave": {
"source.fixAll.ruff": true,
"source.organizeImports.ruff": true
}
}
}If you'd like to run Ruff in lieu of another formatter, you can mark the Ruff extension as your
default Python formatter in settings.json:
{
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
}
}
}| Command | Description |
|---|---|
| Ruff: Fix all auto-fixable problems | Fix all auto-fixable problems. |
| Ruff: Restart Server | Force restart the linter server. |
This extension is based on the Template for VS Code Python tools extensions.
- Install
just, or see thejustfilefor corresponding commands. - Create and activate a virtual environment (e.g.,
python -m venv .venv && source .venv/bin/activate). - Install development dependencies (
just install). - To automatically format the codebase, run:
just fmt. - To run lint and type checks, run:
just check. - To run tests, run:
just test.
nox --session fmtnox --session checknox --session test


