This is due to the default line length for black being longer than you'd like – 88 characters per line.

To decrease the line length, you can use the --line-length flag as documented here:

https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html

For example:

$ black --line-length 80 example.py

Black explains the --line-length setting in more detail here:

https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length

Line length

You probably noticed the peculiar default line length. Black defaults to 88 characters per line, which happens to be 10% over 80. This number was found to produce significantly shorter files than sticking with 80 (the most popular), or even 79 (used by the standard library). In general, 90-ish seems like the wise choice.

If you're paid by the line of code you write, you can pass --line-length with a lower number. Black will try to respect that. However, sometimes it won't be able to without breaking other rules. In those rare cases, auto-formatted code will exceed your allotted limit.

You can also increase it, but remember that people with sight disabilities find it harder to work with line lengths exceeding 100 characters. It also adversely affects side-by-side diff review on typical screen resolutions. Long lines also make it harder to present code neatly in documentation or talk slides.

Emphasis on the final paragraph.

I'd recommend just keeping the default settings. The beauty of Black is that it chooses for you, and therefor preempts any arguments about which way is "best".

Answer from damon on Stack Overflow
Top answer
1 of 7
112

This is due to the default line length for black being longer than you'd like – 88 characters per line.

To decrease the line length, you can use the --line-length flag as documented here:

https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html

For example:

$ black --line-length 80 example.py

Black explains the --line-length setting in more detail here:

https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length

Line length

You probably noticed the peculiar default line length. Black defaults to 88 characters per line, which happens to be 10% over 80. This number was found to produce significantly shorter files than sticking with 80 (the most popular), or even 79 (used by the standard library). In general, 90-ish seems like the wise choice.

If you're paid by the line of code you write, you can pass --line-length with a lower number. Black will try to respect that. However, sometimes it won't be able to without breaking other rules. In those rare cases, auto-formatted code will exceed your allotted limit.

You can also increase it, but remember that people with sight disabilities find it harder to work with line lengths exceeding 100 characters. It also adversely affects side-by-side diff review on typical screen resolutions. Long lines also make it harder to present code neatly in documentation or talk slides.

Emphasis on the final paragraph.

I'd recommend just keeping the default settings. The beauty of Black is that it chooses for you, and therefor preempts any arguments about which way is "best".

2 of 7
72

This is now possible by adding a trailing comma to your last argument.

In your example you would write instead:

def example_function(
    arg_1: str, 
    arg_2: bool, 
    arg_3: int = 0, 
    arg_4: int = 1, 
    arg_5: float = 0.0, # <-- Notice the trailing comma
):
🌐
PyPI
pypi.org › project › black › 18.4a1
black 18.4a1 - The uncompromising code formatter.
Formatting becomes transparent after a while and you can focus on the content instead. Black makes code review faster by producing the smallest diffs possible. Black can be installed by running pip install black. It requires Python 3.6.0+ to run but you can reformat Python 2 code with it, too. ... Black doesn't provide many options. You can list them by running black --help: black [OPTIONS] [SRC]... Options: -l, --line-length INTEGER Where to wrap around.
      » pip install black
    
Published   Apr 12, 2018
Version   18.4a1
Discussions

Python devs that use Black for formatting. When I format with VSCode's black, it ignores the problem of very long lines and formats this way. Does it happen to anyone else?
Black defaults to 88 characters, even though PEP8 is 79 characters and most linters default to that value. You can either adjust your black settings or linter settings to make everything agree. More on reddit.com
🌐 r/vscode
18
30
May 22, 2022
Do you use black with its default line length of 88?
I truly don't get the logic of Black's default. The sole remaining reason for the 80 char limit (79 in Python to allow for a single char pad) is to allow the code to be read in a standard, fixed-with VT100 terminal or emulator, ie over SSH. At 88 you've already decided "screw the people with that constraint", so why not go to 100? Or 120? Or for that matter just not have a line length restriction and have everyone set up soft-wrapping? I know they vaguely wave a hand at some research having been done into the arbitrary choice, but it's still arbitrary. More on reddit.com
🌐 r/Python
25
8
November 8, 2018
Black Fails to Format Single String Longer Than Line Length Limit
Describe the bug A Python file containing a single string assignment longer than the line length limit is not reformatted. To Reproduce Take long_line.py: long = "This is a long line that is longer than 88 characters. I expect Black to s... More on github.com
🌐 github.com
28
November 2, 2020
VS Code Python + Black formatter arguments - python.formatting.blackArgs - Stack Overflow
However, in my python Output pane I get the below: Formatting with black failed. Error: Error: no such option: --line-length 80 More on stackoverflow.com
🌐 stackoverflow.com
🌐
Read the Docs
black.readthedocs.io › en › stable › the_black_code_style › current_style.html
The Black code style - Black 26.3.0 documentation
If you’re paid by the lines of code you write, you can pass --line-length with a lower number. Black will try to respect that. However, sometimes it won’t be able to without breaking other rules. In those rare cases, auto-formatted code will exceed your allotted limit.
🌐
DEV Community
dev.to › adamlombard › vscode-setting-line-lengths-in-the-black-python-code-formatter-1g62
VSCode: Setting line lengths in the Black Python code formatter - DEV Community
March 20, 2024 - In VSCode, go 'Code -> Preferences -> Settings' and search for "python formatting black args". Add two separate arguments, in this order: --line-length and n, where "n" is your desired number of allowed characters per line:
🌐
GitHub
yellowduck.be › posts › vscode-setting-line-lengths-in-the-black-python-code-formatter
🔗 VSCode: Setting line lengths in the Black Python code formatter
In VSCode, go 'Code -> Preferences -> Settings' and search for "python formatting black args". Add two separate arguments, in this order: --line-length and n, where "n" is your desired number of allowed characters per line.
🌐
Readthedocs
test-black.readthedocs.io › en › latest › the_black_code_style.html
The Black code style — Black 18.3a4 documentation
Also, having the closing bracket ... docstring in the example above). You probably noticed the peculiar default line length. Black defaults to 88 characters per line, which happens to be 10% over 80....
🌐
Reddit
reddit.com › r/vscode › python devs that use black for formatting. when i format with vscode's black, it ignores the problem of very long lines and formats this way. does it happen to anyone else?
r/vscode on Reddit: Python devs that use Black for formatting. When I format with VSCode's black, it ignores the problem of very long lines and formats this way. Does it happen to anyone else?
May 22, 2022 - "python.formatting.provider": "black", "python.formatting.blackPath": "~/.local/bin/black", "python.sortImports.path": "~/.local/bin/isort", "python.formatting.blackArgs": ["--line-length=90"], "python.sortImports.args": ["--profile=black"], "[python]": { "editor.formatOnSave": true },
Find elsewhere
🌐
Safjan
safjan.com › home › note › change black line length
Change black line length - Krystian Safjan's Blog
August 31, 2022 - 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", ...
🌐
Reddit
reddit.com › r/python › do you use black with its default line length of 88?
r/Python on Reddit: Do you use black with its default line length of 88?
November 8, 2018 -

I was curious to hear how others deal with this. Do you use the black-default line length of 88 or do you override it to e.g. 79 (pep8 standard)?

I personally have now adjusted my linters to use line length 88 and using black with all its defaults. However, I am not completely sure whether I want it this way, or if I would prefer to keep linters at their defaults (79) and tell black to use that. I can tell that my scripts become a little shorter, at the expense of vertical screen real estate (I like to keep three editor tabs opened, side by side). If you are using black, what are your settings like, and why?

EDIT: I went back to using yapf and line length 79 for now. Reasons being yapf can format on paste, black replaces single quotes with double quotes (this can be turned off, I know), a strange method args formatting choice in black ...and I'm still not convinced the few extra line length chars makes sense to me right now, as so many other things expect 79 and not 88. Maybe I will revisit black later on, once it's out of beta, is more widely adopted/accepted and has a more official blessing (although it being developed by a core dev)...

EDIT 2: After having learned of some yapf limitations and quirks, I switched back to back. But I'm keeping my line lengths at 79 for now. I like the zero-configuration approach to black (although now I am using it with --line-length 79) and I guess I would get used to it. But I can't get behind the 88 line length until there is some type of recognition of this in a future pep, as I personally like 79 just fine and it really is a standard today.

🌐
GitHub
github.com › psf › black › issues › 1802
Black Fails to Format Single String Longer Than Line Length Limit · Issue #1802 · psf/black
November 2, 2020 - One possible solution is to break on the <line length limit minus 1> character and parenthesize if it is not already inside parentheses: long = ( "This is a long line that is longer than 88 characters.
Author   kennytrytek-wf
🌐
Safjan
safjan.com › home › note › black - change max line length
Black - Change Max Line Length - Krystian Safjan's Blog
July 11, 2023 - One of these rules is the maximum line length, which is set by default to 88 characters. This means that any line of code that exceeds 88 characters will be automatically reformatted by Black to fit within this limit.
🌐
PyPI
pypi.org › project › black
black · PyPI
Fix fix_fmt_skip_in_one_liners preview feature to respect # fmt: skip for compound statements with semicolon-separated bodies (#4800) Add no_cache option to control caching behavior. (#4803) ... Implemented BlackDClient. This simple python client allows to easily send formatting requests to blackd (#4774)
      » pip install black
    
Published   Mar 12, 2026
Version   26.3.1
🌐
Datacomy
datacomy.com › python › black › change_line_length
How to Change the Line Length Character Limit in Black | Datacomy
To change the character limit for the Black Python formatter, you can add a file named [pyproject.toml](https://www.python.org/dev/peps/pep-0518/) with the following: [tool.black] line-length = 80 · in your project directory.
🌐
Vercel
black.vercel.app
Black Playground
The recommended line length in Black is 88 characters · Target versionsPython 3.3Python 3.4Python 3.5Python 3.6Python 3.7Python 3.8Python 3.9Python 3.10Python 3.11Python 3.12Python 3.13 ·
🌐
Read the Docs
black.readthedocs.io › en › stable › usage_and_configuration › the_basics.html
The basics - Black 26.3.0 documentation
For example, support for a trailing comma after *args in a function call was added in Python 3.5, so Black will add this comma only if the target versions are all Python 3.5 or higher: $ black --line-length=10 --target-version=py35 -c 'f(a, *args)' f( a, *args, ) $ black --line-length=10 --target-version=py34 -c 'f(a, *args)' f( a, *args ) $ black --line-length=10 --target-version=py34 --target-version=py35 -c 'f(a, *args)' f( a, *args )
🌐
GitHub
github.com › psf › black › issues › 290
Change default line length to 100 · Issue #290 · psf/black
June 2, 2018 - Hi, in the modern era it makes much more sense to have 100 as a default. Some would prefer 120, but 100 makes the most sense as not being too big of a change. The main importance of black is indeed to be "uncompromising", and I feel for ...
Author   kootenpv
🌐
Visual Studio Code
code.visualstudio.com › docs › python › formatting
Formatting Python in VS Code
November 3, 2021 - Formatting makes source code easier to read by human beings. By enforcing particular rules and conventions such as line spacing, indents, and spacing around operators, the code becomes more visually organized and comprehensible. You can view an example on the autopep8 page.
🌐
Safjan
safjan.com › home › note › black - the code formatter
Black - The Code Formatter - Krystian Safjan's Blog
August 11, 2023 - To change the character limit for the Black Python formatter, you can add the following section to pyproject.toml file: ... For info on how to configure black with vscode? See Change black line length.
🌐
freeCodeCamp
freecodecamp.org › news › auto-format-your-python-code-with-black
How to Auto-Format Your Python Code with Black
May 12, 2020 - black --check .: This will check ... to be done to the file but doesn’t modify the file. ... Note that Black defaults to 88 characters for its line length, but you can change that using the “-l” or “- -line-length” ...