🎉 run code quality checks automatically

* installs black and flake8 as pre-commit hooks
* runs only on modified files
This commit is contained in:
julien-talkair 2021-07-01 17:37:43 +02:00
parent bb781ae7f7
commit a0004349f3
3 changed files with 20 additions and 0 deletions

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

@ -0,0 +1,10 @@
repos:
- repo: https://github.com/ambv/black
rev: 21.6b0
hooks:
- id: black
language_version: python3.7
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8

View File

@ -177,6 +177,15 @@ tools installed.
**⚠️ Note that formatting and linting is currently only possible for Python **⚠️ Note that formatting and linting is currently only possible for Python
modules in `.py` files, not Cython modules in `.pyx` and `.pxd` files.** modules in `.py` files, not Cython modules in `.pyx` and `.pxd` files.**
### Pre-Commit Hooks
After cloning the repo, after installing the packages from `requirements.txt`, enter the repo folder and run `pre-commit install`.
Each time a `git commit` is initiated, `black` and `flake8` will run automatically on the modified files only.
In case of error, or when `black` modified a file, the modified file needs to be `git add` once again and a new
`git commit` has to be issued.
### Code formatting ### Code formatting
[`black`](https://github.com/ambv/black) is an opinionated Python code [`black`](https://github.com/ambv/black) is an opinionated Python code

View File

@ -22,6 +22,7 @@ setuptools
packaging>=20.0 packaging>=20.0
typing_extensions>=3.7.4.1,<4.0.0.0; python_version < "3.8" typing_extensions>=3.7.4.1,<4.0.0.0; python_version < "3.8"
# Development dependencies # Development dependencies
pre-commit>=2.13.0
cython>=0.25,<3.0 cython>=0.25,<3.0
pytest>=5.2.0 pytest>=5.2.0
pytest-timeout>=1.3.0,<2.0.0 pytest-timeout>=1.3.0,<2.0.0