Skip to content

Commit

Permalink
Enable pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
greyli committed Jun 21, 2021
1 parent 4897f9a commit 749989d
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/setup-python@v2
- run: python -m pip install --upgrade pip wheel
- run: pip install tox tox-gh-actions
- run: tox -e flake8
- run: tox -e style
- run: tox -e docs
flask1:
name: flask1
Expand Down
30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ci:
autoupdate_schedule: monthly
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.18.3
hooks:
- id: pyupgrade
args: ['--py37-plus']
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.5.0
hooks:
- id: reorder-python-imports
args: ['--application-directories', 'src']
# - repo: https://github.com/psf/black
# rev: 21.5b1
# hooks:
# - id: black
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-implicit-str-concat
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: fix-byte-order-marker
- id: trailing-whitespace
- id: end-of-file-fixer
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ $ source env/bin/activate
$ python -m pip install --upgrade pip setuptools
$ pip install -r requirements/dev.txt
$ pip install -e .
$ pre-commit install
```

For Windows:
Expand All @@ -112,6 +113,7 @@ For Windows:
> python -m pip install --upgrade pip setuptools
> pip install -r .\requirements\dev.txt
> pip install -e .
> pre-commit install
```

[_fork]: https://github.com/greyli/apiflask/fork
Expand Down
1 change: 1 addition & 0 deletions requirements/dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
-r typing.in
pip-tools
tox
pre-commit
14 changes: 13 additions & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ attrs==21.2.0
# via
# jsonschema
# pytest
cfgv==3.3.0
# via pre-commit
click==8.0.1
# via
# mkdocs
Expand All @@ -41,6 +43,8 @@ flake8==3.9.2
# via -r .\requirements\tests.in
ghp-import==2.0.1
# via mkdocs
identify==2.2.10
# via pre-commit
importlib-metadata==4.5.0
# via mkdocs
iniconfig==1.1.1
Expand Down Expand Up @@ -89,6 +93,8 @@ mypy-extensions==0.4.3
# via mypy
mypy==0.902
# via -r .\requirements\typing.in
nodeenv==1.6.0
# via pre-commit
openapi-schema-validator==0.1.5
# via openapi-spec-validator
openapi-spec-validator==0.3.1
Expand All @@ -106,6 +112,8 @@ pluggy==0.13.1
# via
# pytest
# tox
pre-commit==2.13.0
# via -r .\requirements\dev.in
py==1.10.0
# via
# pytest
Expand Down Expand Up @@ -140,6 +148,7 @@ pyyaml==5.4.1
# via
# mkdocs
# openapi-spec-validator
# pre-commit
# pyyaml-env-tag
six==1.16.0
# via
Expand All @@ -155,6 +164,7 @@ toml==0.10.2
# via
# mypy
# pep517
# pre-commit
# pytest
# pytest-cov
# tox
Expand All @@ -163,7 +173,9 @@ tox==3.23.1
typing-extensions==3.10.0.0
# via mypy
virtualenv==20.4.7
# via tox
# via
# pre-commit
# tox
watchdog==2.1.2
# via mkdocs
wheel==0.36.2
Expand Down
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = flake8,py37,py38,py39,pypy37,docs,mypy,flask1
envlist = style,py37,py38,py39,pypy37,docs,mypy,flask1
skip_missing_interpreters = True

[gh-actions]
Expand All @@ -20,6 +20,12 @@ deps=
commands=
flake8 src/apiflask tests examples

[testenv:style]
deps = pre-commit
skip_install = true
commands =
pre-commit run --all-files --show-diff-on-failure

[testenv:docs]
deps = -r requirements/docs.txt
whitelist_externals = mkdocs
Expand Down

0 comments on commit 749989d

Please sign in to comment.