Black formats your code in a nice and deterministic format.

See also

Was lesbaren Code auszeichnet, ist gut beschrieben im Trey Hunners Blog-Post Craft Your Python Like Poetry.


$ pipenv install black


Then you can check the installation with

$ pipenv run black /PATH/TO/YOUR/SOURCE/FILE


With jupyter-black you can already use Black in your Jupyter notebooks.

See also

Integration into other editors such as PyCharm, Wing IDE or Vim is also possible, see Editor integration


In contrast to Black’s standard 88-character formatting, however, I prefer a line length of 79 characters.

For this you can enter the following in pyproject.toml:

line-length = 79

See also

You can get more information about the configuration of Black in the Toml file in pyproject.toml.