Git pre-commit hook for Python code quality

November 09, 2012

Reading time ~1 minute

As you might know I love well formatted code. PEP8 helps us Python developers to create beautiful code.

I have just released a Git pre-commit hook checking the code quality of Python files about to be committed. This hook looks for files ending with .py or with python in the she bang. Then it passes the file to pylint for quality assurance. If the file is too ugly you won’t be able to commit the file.

It is super easy to install the hook. Just download it from my GitHub page and then save it under .git/hooks/pre-commit in your Git repository. That’s it.

The hook can be found at GitHub.

This is what your prompt will look like when you commit a Python file.