🌐
GitHub
github.com › psf › black
GitHub - psf/black: The uncompromising Python code formatter · GitHub
Black is the uncompromising Python code formatter. By using it, you agree to cede control over minutiae of hand-formatting. In return, Black gives you speed, determinism, and freedom from pycodestyle nagging about formatting.
Starred by 41.4K users
Forked by 2.7K users
Languages   Python
🌐
Black
black.readthedocs.io
Black 26.3.0 documentation
Black makes code review faster by producing the smallest diffs possible. Blackened code looks the same regardless of the project you’re reading. Formatting becomes transparent after a while and you can focus on the content instead.
Discussions

Is the damage psf/Black has done to the community reversible?
capable narrow wistful simplistic bells historical bright possessive disagreeable birds This post was mass deleted and anonymized with Redact More on reddit.com
🌐 r/Python
133
0
July 26, 2024
Python black formatting - ROS General - Open Robotics Discourse
One of the real frustrations with contributing and writing python code with the flake8 checker is that previously there hasn’t been a tool like clang_format to automatically strictly format python code for you. In conve… More on discourse.openrobotics.org
🌐 discourse.openrobotics.org
4
March 18, 2020
visual studio code - Python black formatter for vscode not formatting - Stack Overflow
I'm trying to use black as a formatter for Python on VS Code on Ubuntu 20.04 but it's not working on auto save. I've selected black in Python>Formatting:Provider. I'm using prettier as my default More on stackoverflow.com
🌐 stackoverflow.com
code formatting - In Python, how to tweak Black formatter, if possible? - Stack Overflow
I know that Black is an opinionated formatter, but I love everything it does except one major thing. When I have a function with multiple arguments, instead of displaying it like this: def More on stackoverflow.com
🌐 stackoverflow.com
🌐
PyPI
pypi.org › project › black
black · PyPI
The uncompromising code formatter. ... Black is the uncompromising Python code formatter. By using it, you agree to cede control over minutiae of hand-formatting. In return, Black gives you speed, determinism, and freedom from pycodestyle nagging ...
      » pip install black
    
Published   Mar 12, 2026
Version   26.3.1
🌐
Reddit
reddit.com › r/python › is the damage psf/black has done to the community reversible?
r/Python on Reddit: Is the damage psf/Black has done to the community reversible?
July 26, 2024 -

I really don't understand why the Python Black formatter seems to be so popular. What is the point of a non-configurable and highly biased code formatter? I see no benefit in making all the code in the world look the same. They claim they are ending discussions about code formatting, but in reality they have sparked the biggest debate ever in the Python community with their subjective and often contradictory methods that have evolved over decades of established practices without the ability to configure the formatter. [1][2] The single/double quote disaster is just the most prominent example.

There are people out there who put readability above consistency with every other code base in the world that they will never come into contact with.

What bothers me most is the detachment of the Black developers, who dismiss all objections to their style choices as if they were opinions, and end every discussion by saying, you are just expressing an opinion and we prefer ours. But that is not true, there were many reasons, objectively measurable reasons, why this or that decision is better. Someone else might weigh these reasons differently and therefore come to a different conclusion. But the arguments used to enforce Black's decisions have never stood the test of time in a factual discussion.

I also notice that younger developers (< 35 years) are more likely to accept this approach than the more experienced ones.

[1] https://github.com/psf/black/issues/1252

[2] https://github.com/psf/black/issues/373

🌐
Curiousity
curiousity.ca › 2024 › best-practices-black
Best practices in practice: Black, the Python code formatter | Curiousity?
September 27, 2024 - Black’s tagline is “the uncompromising Python code formatter” and it pretty much is what it says on the tin: it can be used to automatically format Python code, and it’s reasonably opinionated about how it’s done with very few options to change. It starts with pep8 compliance (that’s ...
🌐
Xebia
xebia.com › home › blog › partial python code formatting with black & pycharm
Partial Python Code Formatting With Black & PyCharm | Xebia
December 10, 2018 - This causes me to reformat the code, copy the changed lines I wanted to format, revert formatting, and replace my lines by the copied lines. This felt clumsy and so I went to investigate. First, we need to install Black and configure it in PyCharm. It's available via both Pip and Conda, and runs on Python 3.6 and higher, although it can format older Python code too.
🌐
Vercel
black.vercel.app
Black Playground
Playground for Black, the uncompromising Python code formatter.
Find elsewhere
🌐
Openrobotics
discourse.openrobotics.org › ros › ros general
Python black formatting - ROS General - Open Robotics Discourse
March 18, 2020 - One of the real frustrations with contributing and writing python code with the flake8 checker is that previously there hasn’t been a tool like clang_format to automatically strictly format python code for you. In conversations with a friend who works on a large python project I learned about just such a tool.
🌐
Medium
lewoudar.medium.com › black-and-blues-a5e92e047487
Black and Blues. Formatting tools for python | by Kevin Tewouda | Medium
March 27, 2023 - The usage is not different from black since it is based on the latter. # to apply it on a directory and subdirectories $ blue . # to apply it on a file $ blue formatting.py # to only show the differences like Git does $ blue formatting.py --diff
🌐
Luminous Men
luminousmen.com › post › my-unpopular-opinion-about-black-code-formatter
My unpopular opinion about black code formatter
July 25, 2024 - But even PEP8 itself has devoted a whole paragraph to "readability counts" and mentions that a style guide helps avoid bugs as it introduces best practices to avoid code smells. And the key point — consistency is only important as it improves readability. But Black is not about this at all, Black removes visual cues, as it is written in the documentation 'It doesn't take previous formatting into account.
Top answer
1 of 7
18

There are only a few settings you need to setup black as a formatter on VS Code. It seems you got most of it right, but I am doubtful about using relative paths for blackPath (VS Code should have shown an error if the path is indeed incorrect).

I suggest switching to absolute paths.

Here are my settings:

// User Settings

"editor.defaultFormatter": null,
"editor.formatOnSave": false,  // enable per language
"[python]": {
    "editor.formatOnSave": true
},
"python.formatting.provider": "black",
"python.formatting.blackPath": "/usr/local/bin/black"

// Workspace Settings

"python.formatting.blackPath": "/absolute/path/to/venv/with/black",
"python.formatting.blackArgs": [
    "-l 120"
],

First of all, I suggest getting rid of the editor.defaultFormatter setting (or just set it back to the default null). Instead of setting a default for everything, configure your formatter for each language and for each extension. Here, it's null and then I configure python-specific settings then I have separate ones for other languages (ex. JS and C++). You mentioned something about Prettier, and that could be interfering with VS Code using black.

Second, make sure you are modifying the correct settings. VS Code has 3 sets of settings: User, Workspace, and Folder. I normally have the formatOnSave enabled for Python on the User settings, and provider set to black (using system-wide installed black). On a specific workspace, I have a virtual environment and I override the blackPath to the black specifically installed on that virtual environment. You can also just put all the settings in the User settings or use the same system-wide-installed black. But the main point here is to use absolute paths for both (basically copying the output of which black from the console).

Note that, if you specified blackPath to point to a particular virtual environment, make sure to select that same virtual environment on your workspace.

Lastly, you can check for any issues from the Output tab > Python:

2 of 7
2

I was also having the issue. What solved the issue for me was after downloading the Black formatter extension and once the document was open I did a right-click with the mouse and then press "format document". Choose black. I was good to go and had no more issues after that.

🌐
Visual Studio Code
code.visualstudio.com › docs › python › formatting
Formatting Python in VS Code
November 3, 2021 - Alternatively, you can set it as the default formatter for all Python files by setting "editor.defaultFormatter" in your User settings.json file, under a [python] scope. You can open settings.json with the Preferences: Open User Settings (JSON) command. For example, to set Black Formatter as the default formatter, add the following setting to your User settings.json file: "[python]": { "editor.defaultFormatter": "ms-python.black-formatter" } In order to set a formatter extension as an import sorter, you can set your preference under "editor.codeActionsOnSave" in your User settings.json file or your Workspace settings.json file, under a [python] scope.
🌐
Astral
astral.sh › blog › the-ruff-formatter
The Ruff Formatter: An extremely fast, Black-compatible Python formatter
October 24, 2023 - Ruff’s formatter is designed as a drop-in replacement for Black. On Black-formatted Python projects, Ruff achieves >99.9% compatibility with Black, as measured by changed lines. When formatting the Django codebase, for example, Ruff and Black only differ on 34 out of 2,772 files.
Top answer
1 of 7
111

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
):
🌐
Built In
builtin.com › data-science › autopep8-vs-black
Python Auto Formatter: Autopep8 vs. Black | Built In
October 5, 2023 - Black: Black is an auto formatter for Python that converts the entire codebase into its own style to ensure it aligns with the PEP 8 style guide.
🌐
freeCodeCamp
freecodecamp.org › news › auto-format-your-python-code-with-black
How to Auto-Format Your Python Code with Black
May 12, 2020 - jupyter nbextension install https://github.com/drillan/jupyter-black/archive/master.zip — user ... Now you can start formatting your python code in each notebook cell.
🌐
DEV Community
dev.to › adamlombard › how-to-use-the-black-python-code-formatter-in-vscode-3lo0
VSCode: Using Black to automatically format Python - DEV Community
April 4, 2024 - Black is "the uncompromising Python code formatter." It can be configured to automatically format your code whenever you save a file in VSCode.
🌐
Pyrfecter
pyrfecter.com › format-python-code
Format Python code online · Pyrfecter
June 26, 2025 - Code formatters provide consistent ... compatibility. Why not! It's free, easy, and secure because your code never leaves your browser. Pyrfecter uses Black to format your Python code....
🌐
Hacker News
news.ycombinator.com › item
Black, the uncompromising Python code formatter, is stable | Hacker News
January 1, 2022 - Change log: https://black.readthedocs.io/en/latest/change_log.html · Going forward we'll follow our stability policy (https://black.readthedocs.io/en/latest/the_black_code_style/...)