Pre-commit hook for Git checking Python code quality. The hook will check files ending with .py
or that has a she bang containing python
.
Set the threshold for the quality by updating the LIMIT
value in the pre-commit
hook.
Download the hook (or just copy it from GitHub) and save it in your Git repo as .git/hooks/pre-commit
.
Don't forget to make it executable.
The commit hook will automatically be called when you are running git commit
. If you want to skip the tests for a certain commit, use the -n
flag, git commit -n
.
Open the pre-commit
script and update the LIMIT
value according to your needs. E.g.
LIMIT = 8.0
The hook supports custom command line options to be specified. Those can be added to the PYLINT_PARAMS
inside the pre-commit
script. E.g.
PYLINT_PARAMS = '--rcfile=/path/to/project/pylint.rc'
This commit hook is written in Python and has the following requirements:
- pylint (
sudo pip install pylint
) - Python >2.5 and <3.0
- Bug when skipping init.py files fixed. Wrong path was checked under some circumstanses
- Added support for negative pylint scores #4
- Added support for custom command line params to pylint #6
- Fixed bug #3 Empty .py files fails according to pylint
- Fixed bug #1 Files parsed number is not increased
- Fixed bug with non-python files getting checked, if they contained
python
on the first row
- Added support for handling moved or deleted files
- Initial release of the commit hook