visual studio code – Format on save duplicates the final line of Python files
Using multiple formatters is known to cause issues in VS Code, including the problem of duplicating lines.
The easiest solution is to enable only one extension which can handle all formatting. Ruff can do this with the following settings:
"editor.codeActionsOnSave": {
"source.organizeImports.ruff": "explicit"
},
"editor.formatOnSave": true,
If you must use isort/Black, you need to set the correct profile as described in their docs. In this case, the issue is being caused by isort and Black having different defaults for line length.
Read more here: Source link
