Skip to content

Setting up a GIt hook to do `flake8` and `isort`

Martin Hafskjold Thoresen edited this page Oct 18, 2016 · 2 revisions

We will set up a Git-hook to run flake8 and isort -rc each time we commit, in order to avoid waiting for 15 minutes on CirclejerkCI, just to know that some imports in a migration was in the wrong order.

Step 0

You need isort and flake8. Duh.

Step I

Create the file .git/hooks/pre-commit (the .git/ directory is located in the top level of the project)

Step II

Put this in:

#!/bin/bash
isort -rc lego
flake8 lego

Step III

You are done. Enjoy not failing on CI each time you push 💯

Clone this wiki locally