-
Notifications
You must be signed in to change notification settings - Fork 4
Local checking: pre commit
Jiri Popelka edited this page Jul 4, 2019
·
7 revisions
To make sure our code is PEP 8 compliant, we use:
There's a pre-commit config file (.pre-commit-config.yaml
) in each repo.
To utilize pre-commit, install pre-commit (, ) with pip3 install pre-commit
and then either:
-
pre-commit install
- to install pre-commit into your git hooks. pre-commit will from now on run all the checkers/linters/formatters on every commit. If you later want to commit without running it, just rungit commit
with-n/--no-verify
. - Or if you want to manually run all the checkers/linters/formatters, run
pre-commit run --all-files
.
$ pre-commit run --all-files
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
Trim Trailing Whitespace.................................................Failed
hookid: trailing-whitespace
Files were modified by this hook. Additional output:
Fixing release-conf.yaml
Fixing CONTRIBUTING.md
$ pre-commit run --all-files
Trim Trailing Whitespace.................................................Passed
- example
.pre-commit-config.yaml
:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-merge-conflict
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace
- id: flake8
args: [--max-line-length=100]
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3.6
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.711
hooks:
- id: mypy
args: [--no-strict-optional, --ignore-missing-imports]