ucam-department-of-psychiatry / camcops

Cambridge Cognitive and Psychiatric Test Kit (CamCOPS)
Other
12 stars 8 forks source link

Replace our pre-commit hook script with third party pre-commit package #253

Closed martinburchell closed 1 year ago

martinburchell commented 1 year ago

Commits are getting too slow with Black and PEP8 checks on every python file for every commit. We only want to check the files that are being committed .

pre-commit will do this for us. For now I've just added a few checks, namely:

We might want to add more from the complete list of supported hooks

Usage:

Remove our pre-commit hook:

$ rm ~/workspace/camcops/.git/hooks/pre-commit

Inside the virtualenv:

$ cd ~/workspace/camcops/server
$ pip install -e .
$ pre-commit install

This will now run pre-commit on any committed files.

To run on all files:

$ pre-commit run --all-files

This change also ignores some PEP8 issues that were previously undetected.