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
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.
importStrategy
fromEnvironment
Strategy for loading the ruff executable. fromEnvironment picks up Ruff from the environment, falling back to the bundled version if needed. useBundled uses the version bundled with the extension.
showNotification
off
Whether a notification should be 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.
Example configurations
You can configure Ruff to autofix violations on-save by enabling the source.fixAll action in
settings.json:
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:
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:
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:
charliermarsh/ruff-vscode
Ruff extension for Visual Studio Code
A Visual Studio Code extension with support for the Ruff linter. Available on the Visual Studio Marketplace.
The extension ships with
ruff==0.0.259
.(Interested in using Ruff with another editor? Check out
ruff-lsp
.)Highlights
"Quick Fix" actions for auto-fixable violations (like unused imports)
"Fix all": automatically fix all auto-fixable violations
"Organize Imports":
isort
-compatible import sortingUsage
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
[]
ruff
. E.g"args": ["--config=/path/to/pyproject.toml"]
.error
[]
ruff
executables, to try in order. E.g.["/path/to/ruff"]
.[]
fromEnvironment
ruff
executable.fromEnvironment
picks up Ruff from the environment, falling back to the bundled version if needed.useBundled
uses the version bundled with the extension.off
true
source.organizeImports
actions.true
source.fixAll
actions.Example configurations
You can configure Ruff to autofix violations on-save by enabling the
source.fixAll
action insettings.json
:You can configure Ruff to organize imports on-save by enabling the
source.organizeImports
action insettings.json
: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
: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 followingsettings.json
: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
andsource.organizeImports
actions via the followingsettings.json
:If you'd like to run Ruff in lieu of another formatter altogether, be sure to unset the
editor.defaultFormatter
insettings.json
:Commands
Requirements
This extension requires a version of the VSCode Python extension that supports Python 3.7+. Ruff itself is compatible with Python 3.7 to 3.11.
Development
This extension is based on the Template for VS Code Python tools extensions.
Getting Started
just
, or see thejustfile
for corresponding commands.python -m venv .venv && source .venv/bin/activate
).just install
).just fmt
.just check
.just test
.Development
nox --session fmt
nox --session check
nox --session test