Skip to content

Python coding style

Jodasue edited this page Dec 8, 2021 · 5 revisions

Enforcing python pep8 code style

In order to produce consistent code, we are enforcing pep8 style conventions via flake8 checks on git commits: pep8 style conventions.

The easiest way to do this is to install autopep8 via conda:

conda install -c conda-forge autopep8.

For consistency you should install the following config file in ~/.config/pep8:

[pycodestyle]
ignore = E221, E402
statistics = True
max-line-length = 99

Then you can preview the changes to a code via:

autopep8 --diff <filename>

If you are happy with the proposed changes, you can actually enforce them with:

autopep8 --in-place <filename>

Clone this wiki locally