Git pre-commit hook for checking coding style of Python code. The hook requires pep8. It will check files with the .py extension and files that contain #! (shebang) and python in the first line. Heavily inspired by and partly based on git-pylint-commit-hook by Sebastian Dahlgren.
Since pep8 itself, by default, looks for a setup.cfg file in the repository root directory, so does this script. The script works without the setup.cfg file. The options for the script can either be placed in the [pep8_pre_commit_hook] section of the configuration file or be passed as command line parameters. If the same option is specified in both the configuration file and the parameters, the configuration file takes precedence.
Install via PyPI
pip install git_pep8_commit_hook
Having installed the script, if you add it to your pre-commit file which should be placed in the hooks subfolder for the Git folder (usually .git/hooks), it will be called automatically when you run git commit. If you want to skip the checks for a certain commit, you can add the -n flag and run git commit -n.
By default, the script looks for a setup.cfg in the root directory of your repository. If the script does not find a configuration file, it uses default settings. The file might look like this:
[pep8] ignore = E226,E302,E41 max-line-length = 79 [pep8_pre_commit_hook] max-violations-per-file = 5
The [pep8] section is used by pep8. The [pep8_pre_commit_hook] section is used by the commit hook script. You may specify the following options:
Alternatively you can pass the above directly to the commit hook script as arguments. In addition to the above, you can also pass the following arguments to the script:
The tests are written using pytest. You can run the tests without installing pytest and without installing the script by typing python runtests.py. Alternatively, you can install pytest by running pip install pytest. The script itself can be installed in development mode by running pip install -e . from the root directory of the repository. Then the tests can be run by executing py.test.
This commit hook is written in Python and has the following requirements:
TODO: Figure out how to actually get changelog content.
Changelog content for this version goes here.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|File Name & Checksum SHA256 Checksum Help||Version||File Type||Upload Date|
|git_pep8_commit_hook-0.1.0-py2.py3-none-any.whl (8.8 kB) Copy SHA256 Checksum SHA256||py2.py3||Wheel||Sep 11, 2015|
|git_pep8_commit_hook-0.1.0.tar.gz (9.7 kB) Copy SHA256 Checksum SHA256||–||Source||Sep 11, 2015|