Home > Software engineering >  How to stop VS Code from removing Python unused imports on save
How to stop VS Code from removing Python unused imports on save

Time:08-30

Looking for general advice, as I'm not completely sure what is causing this behavior which I did not encounter until recently. I'm finding it quite annoying because it can delete imports if I comment out a line during development.

CodePudding user response:

Update: figured out one solution.

Adding the following to your settings.json file (you can access it on Windows with ctrl shift p followed by a search for settings)

"editor.codeActionsOnSave": {
    ... [other settings] ...
    "source.organizeImports": false
}

Note: ensure that "editor.codeActionsOnSave" is not defined elsewhere (aside from language specific places), as this prevented the fix from working the first time I tried it.

CodePudding user response:

Check your extensions might have the Auto extension or Accessibility extension installed.

Revert back if this did not work.

  • Related