flake8 PEP8 quick start

PEP8 code style benefits code readability. “flake8” checks for PEP8 compliance, as well as catch some syntax errors in unexecuted code. flake8 is typically part of continuous integration.

pip install flake8

in the top directory of the particular Python package type:

flake8

flake8 is configured via the per-project top-level file “.flake8:

[flake8]
max-line-length = 132
exclude = .git,__pycache__,doc/,docs/,build/,dist/,archive/

If lines that violate PEP8 must remain as-is, individual lines can be exempted from PEP8 with noqa pragma like:

3==1+2  # noqa: E225