Feat/pre commit checks
- Added pre-commit hooks which:
- isort on
.py
and.ipynb
- flake8 on
.py
and.ipynb
- nbstripout
- rstcheck
- check-added-large-files
- check-ast
- check-json
- check-yaml
- check-toml
- end-of-file-fixer
- trailing-whitespace
- check-docstring-first
- check-merge-conflict
- mixed-line-ending
- isort on
- Hooks run as part of the
check
stage in the CI - Fixed some of the issues:
- EoF
- Trailing whitespace
- isort (but only for .py)
I included a lot of other changes and fixes in the original MR (https://git.xfel.eu/gitlab/detectors/pycalibration/merge_requests/411) before figuring out how to get the checks to run only on changed files, which meant that the MR implementing pre-commit checks also refactored a decent chunk of code. It would be better to do that refactoring in separate MRs so I've closed the original one and opened this to replace it.
@ahmedk @danilevc @hammerd feel free to review when you have time
TODO:
-
Add pre-commit to requirements.txt -
Don't mutate the code during pre-commit checks- changed my mind about this a few times, left it to mutate the code as that is only done on staged files, so any mutations can be reverted by undoing changes anyway. Added an explanation on this to the readme instead. -
Add info to the readme and to the wiki -
Add explanation of what each of the checks is for in more detail -
Add scripts to execute w/ diff-only (same as the CI pipeline)
Edited by Robert Rosca