-
Notifications
You must be signed in to change notification settings - Fork 226
Development environment
The AiiDA pre-commit hooks help you write clean code by running
- code formatting
- syntax checking
- static analysis
- checks for missing docstrings
- checks for consistency of dependencies and version numbers
- ...
locally at every commit you make. We currently use yapf and prospector, but more tools may follow.
Set up the hooks as follows:
cd aiida_core pip install -e .[dev_precommit] pre-commit install pre-commit run # test running the hooks # from now on, hooks will check changed files on every commit
- Note:
-
- If you work in a
conda
environment, you may need toconda install virtualenv
to avoid problems with virtualenv inside conda. - On Ubuntu-18.04 you may need to
sudo apt install ruby-dev
- If you work in a
- Useful commands:
-
- Use
pre-commit run
to run the checks without committing - If you ever need to commit a 'work in progress' you may skip the checks via
git commit --no-verify
. Yet, keep in mind that the pre-commit hooks will also run (and fail) at the continuous integration stage when you push them upstream. - For historical reasons, some code files are excluded from pre-commit checks in aiida. When touching such a file, please try to remove them from the exclude list
.pre-commit-config.yaml
.
- Use
When writing python code, a more than reasonable guideline is given by the Google python styleguide http://google-styleguide.googlecode.com/svn/trunk/pyguide.html. The documentation should be written consistently in the style of sphinx.
And more generally, write verbose! Will you remember after a month why you had to write that check on that line? (Hint: no) Write comments!
Note
Before committing, always run:
verdi devel tests
to be sure that your modifications did not introduce any new bugs in existing code. Remember to do it even if you believe your modification to be small - the tests run pretty fast!