configure pre-commit

This commit is contained in:
Thomas Grainger 2021-03-23 00:16:25 +00:00
parent 370e16b117
commit 6a8dfb6424
No known key found for this signature in database
GPG Key ID: E452A1247BAC1A88
4 changed files with 37 additions and 16 deletions

30
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,30 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.11.0
hooks:
- id: pyupgrade
args:
- --keep-percent-format
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.0
hooks:
- id: flake8
- repo: https://github.com/asottile/yesqa
rev: v1.2.2
hooks:
- id: yesqa
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: mixed-line-ending

View File

@ -24,11 +24,9 @@ matrix:
env: TOX_ENV=tests
- python: 3.9
env: TOX_ENV=tests
- env: TOX_ENV=black
- env: TOX_ENV=mypy
- env: TOX_ENV=apidocs
- env: PUSH_DOCS=true
- env: TOX_ENV=check-manifest
script:
- if [[ -n "${TOX_ENV}" ]]; then tox -e $TOX_ENV; fi

View File

@ -48,3 +48,8 @@ mypy =
[bdist_wheel]
universal = 1
[flake8]
max-line-length = 88
extend-ignore =
E203, # whitespace before : is not PEP8 compliant (& conflicts with black)

16
tox.ini
View File

@ -7,7 +7,6 @@ isolated_build = true
envlist =
flake8,
tests,
check-manifest,
apidocs
@ -17,25 +16,18 @@ wheel_build_env = build
deps =
tests: coverage
apidocs: pydoctor
check-manifest: check-manifest
black: black
black-reformat: black
lint: pre-commit
extras =
mypy: mypy
tests: scripts
setenv =
black: BLACK_LINT_ARGS=--check
commands =
python -V
black: black {env:BLACK_LINT_ARGS} .
lint: pre-commit run --all-files --show-diff-on-failure
apidocs: pydoctor -q --project-name incremental src/incremental
check-manifest: check-manifest -v
tests: coverage --version
tests: {envbindir}/trial --version
tests: coverage erase
@ -47,10 +39,6 @@ commands =
tests: coverage html
mypy: mypy src
[testenv:black-reformat]
setenv =
; Clear the --check flag
BLACK_LINT_ARGS=
[testenv:build]
# empty environment to build universal wheel once per tox invocation