Search code examples
pythonvisual-studio-codepylance

How to turn off VS Code's Python auto-fix feature in Pylance?


I need to make some targeted edits in a Python source tree. VSCode's Pylance extension is "helping" me by removing unused imports in a file, every time I save the file.

How can I turn this feature off, aside from disabling the Pylance extension entirely?


Solution

  • Add the following configuration in settings.json to turn off automatic deletion of unused imports

        "editor.codeActionsOnSave": {
            "source.fixAll": false,
        },
    

    There are two settings.json files. The Workspace settings.json file will overwrite the same configurations in User settings.json

    enter image description here