The Black Formatter – Python
Question:
I just started using the Black Formatter module with VSCode everything was going well till I just noticed that it uses double quotes over single quotes which I already was using in my code.. and it overrode that..
So, is there an Black Argument that I could add to VSCode which solves this problem?
Thanks.
Answers:
You can use the --skip-string-normalization
option at the command line, or in your VSCode options.
See here: https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#strings
For example:
{
...
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--skip-string-normalization",
"--line-length",
"100"
]
...
}
Good luck!
--skip-string-normalization
or -S
for short
{
...
"python.formatting.blackArgs": [
"-S"
],
...
}
I don’t know how it works for you all of that:
{
...
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--skip-string-normalization"
]
...
}
or
{
...
"python.formatting.blackArgs": [
"-S"
],
...
}
I’ve tried everything and THE ONLY works for me is:
"black-formatter.args": ["-S"]
And VSCode for some reason installed via pip install -U black
, don’t know it is crucial or not.
I just started using the Black Formatter module with VSCode everything was going well till I just noticed that it uses double quotes over single quotes which I already was using in my code.. and it overrode that..
So, is there an Black Argument that I could add to VSCode which solves this problem?
Thanks.
You can use the --skip-string-normalization
option at the command line, or in your VSCode options.
See here: https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#strings
For example:
{
...
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--skip-string-normalization",
"--line-length",
"100"
]
...
}
Good luck!
--skip-string-normalization
or -S
for short
{
...
"python.formatting.blackArgs": [
"-S"
],
...
}
I don’t know how it works for you all of that:
{
...
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--skip-string-normalization"
]
...
}
or
{
...
"python.formatting.blackArgs": [
"-S"
],
...
}
I’ve tried everything and THE ONLY works for me is:
"black-formatter.args": ["-S"]
And VSCode for some reason installed via pip install -U black
, don’t know it is crucial or not.