2021-11-29
Change black line length
X:Black - The Code Formatter X::Black - Change Max Line Length
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
- PEP8 recommends a line length of 79 characters (72 for docstrings)
- Black sets line lengths to 88 characters by default
- The Django docs recommend a maximum line length of 119 characters (79 for docstrings)
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)