I am trying to create some settings to auto lint and format Python files when saving. I have the settings I desire for Python but when editing other files such as XML, VSCode will automatically format them as well. Is there a way I can get VSCode to only format the Python files?
Here are my settings for formatting and linting:
"python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
"--max-line-length=240",
"--disable=C0111,unused-import"
],
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"line-length", "250"
],
"python.linting.lintOnSave": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"editor.formatOnSave": true, VS Code will use its available formatters (built-in + installed extensions) to auto-format your XML files. It's not about your Python settings, and it's probably more confusing approaching it from preventing the Python formatter to affect other files.