Collection of pre-commit hooks.
-
pip-compile simply runs
pip-compilebefore every commit.- Why? This makes sure no one you didn’t 1. forget to run
pip-compileafter modifyingrequirements.in, 2. directly modifyrequirements.txtwithout modifyingrequirements.in, 3. forget to stage either in Git, 4. have inconsistentrequirements.txtandrequirements.infor any reason. - Out-of-scope: It won’t run
pip-syncfor you or make sure your environment is synced. You have control over that. - N.B. Make sure when pre-commit is running that the right Python virtual is activated if applicable and pip-tools is installed, so the hook can find the right
pip-compileexecutable. Otherwise, the hook will fail.
- Why? This makes sure no one you didn’t 1. forget to run
-
pip-compile-multi is the same but for multiple
requirements.infiles.- How it works: It runs
pip-compilefor every file named*requirements.inin the root directory. - Out-of-scope: This won’t work for requirements file ignored by Git. They must be staged for pre-commit to notice the
.inand.txtfiles have fallen out of sync and block the commit. - N.B.: same as for
pip-compile.
- How it works: It runs
-
uv-compile is the same as
pip-compilebut uses uv instead of pip-tools so it can run ultra-fast.- N.B. Make sure when pre-commit is running that the right Python virtual is activated if applicable and uv is installed, so the hook can find the right
uvexecutable. Otherwise, the hook will fail.
- N.B. Make sure when pre-commit is running that the right Python virtual is activated if applicable and uv is installed, so the hook can find the right
-
make-migrations makes sure Django migration files have been created.
- How it works: It runs
python manage.py makemigrations --check --dry-runto make sure no migrations are left to be created. - Out-of-scope: It won’t make the migrations for you. If the hook fails, run
python manage.py migrations, stage the migration files, and try committing again. - Out-of-scope: It won’t run
python manage.py migratefor you or check that migrations have been applied. You have control over that. - N.B.: Make sure when the pre-commit is running that the right Python virtual environment is activated if applicable and there is a Django
manage.pyfile you can run. Else, the hook will fail.
- How it works: It runs
You can try out hooks in this repo without installing them by running
pre-commit try-repo https://github.com/Axle-Health/pre-commit-hooksTo install a pre-commit hook from this repo, simply add something like
- repo: https://github.com/Axle-Health/pre-commit-hooks
rev: 1.1.0
hooks:
- id: pip-compile
- id: make-migrationsto your .pre-commit-config.yaml file. Or if you don’t have one already, install pre-commit first