12

I'm writing Python code in VS Code and have recently installed the Ruff linter and its associated VS Code extension. One thing I'm finding frustrating is that when I write a symbol name and want to use VS Code's "Quick Fix" to add an import for it, the first option that comes up is "Ruff: Disable" rather than "Add import".

Quick Fix showing "Ruff: Disable" first and Add import second

This isn't the end of the world, of course, I can press down arrow to select the action I want. But it does add an extra step and is an annoyance. Is there a way I can get these actions in the order I want?

A few versions if they're relevant:

  • Ruff extension, this happens with both v2023.16.0 and v2023.17.11351528
  • Pylance v2023.6.10
  • Python VS Code Extension v2023.8.0

VS Code version:

Version: 1.78.2 (Universal)
Commit: b3e4e68a0bc097f0ae7907b217c1119af9e03435
Date: 2023-05-10T14:44:45.204Z
Electron: 22.5.2
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Darwin arm64 22.5.0
Sandboxed: Yes
3
  • 2
    A feature request has existed in[ Github](github.com/astral-sh/ruff-vscode/issues/199), and I created a new one for you in vscode-Python. Commented Jun 13, 2023 at 1:56
  • @MingJie-MSFT had his new issue closed without the needed 20 votes. :( Commented Aug 20, 2024 at 23:31
  • May 2025 still no way to change the order of the quick fixes. I don't understand why "disable for this line" would be the first option, in what world your first choice is to disable the warning instead of fixing it?! Commented May 6 at 14:06

1 Answer 1

5

There doesn't seem to be any way to adjust the order of these quick fixes. But it's possible to move "Add import" to the top of to the list by removing "Ruff: disable" quick fixes entirely.

Here's the setting for your .vscode/settings.json:

{
    "ruff.codeAction.disableRuleComment": {
        "enable": false
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.