7

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.

AMC
  • 2,642
  • 7
  • 13
  • 35
Muhammad Hawash
  • 126
  • 1
  • 1
  • 10

3 Answers3

19

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!

yardstick17
  • 4,322
  • 1
  • 26
  • 33
FlipperPA
  • 13,607
  • 4
  • 39
  • 71
8

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.

OM26R
  • 127
  • 1
  • 9
2

--skip-string-normalization or -S for short

{
    ...

    "python.formatting.blackArgs": [
        "-S"
    ],
    ...
}
Al Mahdi
  • 635
  • 1
  • 9
  • 16