flake8 PEP8 quick start
PEP8 code style is essential for good code readability.
flake8
is the prime tool to check for PEP8 compliance, as well as catch syntax errors in unexecuted code that could be a security or stability issue.
That is, a CI with less than 100% code coverage will miss issues that end users may see.
Thus, flake8
should be part of your
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
, which may look like:
[flake8]
max-line-length = 132
exclude = .git,__pycache__,doc/,docs/,build/,dist/,archive/
Sometimes there are lines that violate PEP8, but they must remain as is.
Individual lines can be exempted from PEP8 with noqa
pragma like
3==1+2 # noqa: E225