Closed pylang closed 3 years ago
this can be fixed using vscode feature instead:
settings.json
"[python]": {
"files.trimTrailingWhitespace": true,
},
...
Black already does this.
richard-26@ubuntu-laptop:~/programming/tools/ghprcl$ black test.py
reformatted test.py
All done! ✨ 🍰 ✨
1 file reformatted.
richard-26@ubuntu-laptop:~/programming/tools/ghprcl$ diff -u --color orig.py test.py
--- orig.py 2020-07-28 17:45:02.959401063 -0400
+++ test.py 2020-07-28 17:44:46.307273954 -0400
@@ -1 +1 @@
-s = "Hello world!"
+s = "Hello world!"
This seems like a problem with how Visual Studio Code handling of diffs. Maybe related to this?
Environment:
Ubuntu 18.04.04 LTS
CPython 3.8.1
19.10b0
Closing as this is most likely an issue with VSCode, not Black.
Try these in <project_root>/.vscode/settings.json
:
{
"python.formatting.provider": "black",
"[python]": {
"files.trimTrailingWhitespace": true,
"editor.formatOnSave": true
}
}
Is your feature request related to a problem?
Running black (in VSCode) does not remove trailing whitespaces.
s = 'Hello world!"_ _
Describe the solution you'd like
Rather, I'd like black to remove trailing whitespace on all lines.
s = 'Hello world!"
Describe alternatives you've considered
I have to do a followup "Trim Whitespace" command in VSCode. I'd like this to be part of black by default.
There are some prior issues (#567) regarding trailing whitespace inside strings. Removing trailing whitespace by default can clean up code and even save some wasted space.