Style Guidelines and Enforcement¶
General Coding Style¶
Please stick to the coding style described by PEP8. PEP8 is one of the standard worldwide stylistic conventions for coding in Python.
Class and function docstrings should follow the numpydoc conventions.
Further, Landlab-specific advice for developing your own components can be found in the component development guide.
Many modern text editors, e.g., Atom, provide interactive tools to examine your code as you edit it and highlight where it diverges from standards.
Style enforcement¶
All tools used for development are specified in our environment-dev.yml
file.
If you followed the
developer installation instructions you have
everything you need in the landlab_dev
conda environment.
Currently we check for all the flake8
violations
and pycodestyle
violations
except for (as defined in our setup.cfg
)
E203: whitespace before
E501: line too long (n > 88 characters)
W503: line break before binary operator
To format files to meet these standards, we recommend using isort + black.
You can run
$ make pretty
from the main landlab directory in a terminal to run both isort and black on your code.
To check if your files meet the standards that are enforced under continuous integration, we use flake8. You can run
make lint
from the top level directory or
flake8 <file-to-check>