2021-11-29    Share on: Twitter | Facebook | HackerNews | Reddit

Change black line length

X:Black - The Code Formatter X::Black - Change Max Line Length

black logo

Project settings

To change the character limit for the Black Python formatter, you can add the following section to pyproject.toml file:

[tool.black]
line-length = 119

vscode black formatter line length

You can configure the black formatter in VSCode via Code -> Preferences -> Settings and then search for "python formatting black args" phrase.

in two separate lines provide the line length argument and it's value:

--line-length`
100

In the second line, 100 is the desired limit for the maximum line length.

You can add the information to the formatting section of settings.json which can be found in the project's .vscode directory

{
    "python.formatting.provider": "black",
    "python.formatting.blackArgs": ["--line-length", "120"],
    "python.linting.enabled": true
}

(credits to user mrx for this hint)