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.

Asked By: Muhammad Hawash

||

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!

Answered By: FlipperPA

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

{
    ...

    "python.formatting.blackArgs": [
        "-S"
    ],
    ...
}
Answered By: Al Mahdi

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.

Answered By: OM26R
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.