pythonvisual-studio-codepython-black

The 'Black' formatter - Python


I just started using the 'Black' formatter module with Visual Studio Code. 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 Visual Studio Code which solves this problem?


Solution

  • You can use the --skip-string-normalization option at the command line, or in your Visual Studio Code options.

    See The Black code style, Strings.

    For example:

    {
        ...
        "python.formatting.provider": "black",
        "python.formatting.blackArgs": [
            "--skip-string-normalization",
            "--line-length",
            "100"
        ]
        ...
    }