Welcome to git-pylint-commit-hook’s documentation!¶
Contents:
Installation¶
Use pip
to install git-pylint-commit-hook
.
pip install git-pylint-commit-hook
The command git-pylint-commit-hook
will now be accessible in your system.
Usage¶
Basic configuration¶
To use git-pylint-commit-hook
in a project, create a new file under /project/root/.git/hooks/pre-commit
and add the following to that file:
#!/usr/bin/env bash
git-pylint-commit-hook
Save the file and make it executable:
chmod +x .git/hooks/pre-commit
Your Python files should now be checked upon commit.
Command line options¶
The git-pylint-commit-hook
can be configured using command line options. The command line options are:
--limit LIMIT Score limit, files with a lower score will stop the
commit. Default: 8.0
--pylint PYLINT Path to pylint executable. Default: pylint
--pylintrc PYLINTRC Path to pylintrc file. Options in the pylintrc will
override the command line parameters. Default:
pylintsearch order
--pylint-params PYLINT_PARAMS
Custom pylint parameters to add to the pylint command
--suppress-report Suppress report output if pylint fails
--always-show-violations
Show violations in case of pass as well
--version Print current version number
--ignore IGNORED_FILES
Add regex to blacklist files or directories, allowing
to avoid running pylint those files.
--stash Stash any unstaged changes while linting (changes are
unstashed automatically unless the process is forcibly
killed)
You can simply append those to the command created in the Basic configuration above.
Support for .pylintrc
files¶
git-pylint-commit-hook
will automatically find your pylint configuration files, according to the pylint configuration file default read order. Any configuration found for the project will be used in the git-pylint-commit-hook
.
You can also define a custom pylint configuration file using the --pylintrc
command line option.
pylint configuration¶
Settings are loaded by default from the .pylintrc
file in the root of your repo.
[pre-commit-hook]
command=custom_pylint
params=--rcfile=/path/to/another/pylint.rc
limit=8.0
command
is for the actual command, for instance if pylint is not installed globally, but is in a virtualenv inside the project itself.
params
lets you pass custom parameters to pylint
limit
is the lowest value which you want to allow for a pylint score. Any lower than this, and the script will fail and won’t commit.
Any of these can be bypassed directly in the pre-commit hook itself. You can also set a different default place to look for the pylintrc file.
License¶
APACHE LICENSE 2.0 Copyright 2013 Sebastian Dahlgren
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Overview¶
The git-pylint-commit-hook
is a tool for checking Python code using pylint
before the code is committed to git.
All files that end with .py
or that have python
in the she bang will be automatically checked before they are committed to the repo.
Author¶
This project is maintained by Sebastian Dahlgren (GitHub | Twitter | LinkedIn)
Source code¶
The source code is available on the projects GitHub repository.
\ Sort by:\ best rated\ newest\ oldest\
\\
Add a comment\ (markup):
\``code``
, \ code blocks:::
and an indented block after blank line