python3 formatting with black

Date: 2019/09/02 (initial publish), 2021/07/16 (last update)

Source: en/

Previous Post Top Next Post


I see formatting consistency provided by the black command helps me.

The black is available as Debian package and its upstream is at

Lint tools before black

These are basic lint tools before black.

Install black

 $ sudo apt install python3-black

Use black

 $ black a-python-code-directory/


 $ black

Skip Lint prigram

Line with #NOQA at the end are skipped by pycodestyle for PEP-8 lint.

Lines between # fmt: off and # fmt: on are skipped by the black.

Make black to work with other tools

Adding followings to pyproject.toml may be useful.

max-line-length = 88
select = C,E,F,W,B,B950
ignore = E203,W503,W504

include_trailing_comma = true
line_length = 88
multi_line_output = 3


Other programs

Previous Post Top Next Post