I want to use autosave in Visual Studio Code and apply commonly used tools like flake8, mypy, isort, and black.
Flake8, mypy, and black work fine, but isort doesn’t work at all.
Is there a way to solve this problem?
My settings.json file looks like this:
{
"python.terminal.activateEnvInCurrentTerminal": false,
"python.defaultInterpreterPath": "${workspaceFolder}\.venv\Scripts\python.exe",
"python.linting.enabled": true,
"python.linting.lintOnSave": true,
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.flake8Path": "${workspaceFolder}\.venv\Scripts\pflake8.exe",
"python.linting.mypyEnabled": true,
"python.formatting.provider": "black",
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"editor.formatOnSave": true
}
}
2
Answers
I have solved this issue. I did not know that "isort" was a default in vscode, and so I uninstalled it.
I have reinstalled "isort". And I have modified the "settings.json" as follows:
You can try adding the following line to your settings.json file:
"python.sortImports.path": "${workspaceFolder}\.venv\Scripts\isort.exe"
After that, save the settings.json file and restart VS Code.
Hope this answer can help you