Skip to content

PyPI version

Python formatting

There is a variety of style checkers (tools that give a feedback) and autoformatters (tools that are able to fix the formatting violations automatically).

Existing type checkers and autoformatters

pycodestyle

Checks Python code against some of the style conventions in PEP 8.

autopep8

Automatically fixes most of the formatting issues reported by pycodestyle. Since PEP 8 is rather liberal, autopep8/pycodestyle don't modify code too much.

black

A PEP 8 compliant opinionated autoformatter with its own style, going further than autopep8/pycodestyle. Style configuration options are deliberately limited to a minimum. Black aims for readability and reducing git diffs. Black is an easy to use tool, with sensible and useful defaults. Its style is very elegant.

yapf

Autoformatter that can be configured to support different styles.

isort

Sorts imports alphabetically, and separates them into sections, according to their type.


Last update: June 7, 2023