-
Notifications
You must be signed in to change notification settings - Fork 4
Local checking: pre commit
Jiri Popelka edited this page Feb 12, 2020
·
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/psf/black
rev: stable
hooks:
- id: black
language_version: python3.6
- repo: https://github.com/prettier/prettier
rev: 1.19.1
hooks:
- id: prettier
exclude: tests_recording/test_data/*
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-merge-conflict
- id: check-yaml
- id: detect-private-key
exclude: tests/integration/conftest.py
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
args:
- --max-line-length=100
- --per-file-ignores=files/packit.wsgi:F401,E402
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.761
hooks:
- id: mypy
args: [--no-strict-optional, --ignore-missing-imports]
- repo: https://github.com/packit-service/pre-commit-hooks
rev: master
hooks:
- id: check-rebase
args:
- git://github.com/packit-service/packit.git
- to update the config run
pre-commit autoupdate