misc: add isort (#52856)

This commit is contained in:
Lauréline Guérin 2021-04-08 11:24:47 +02:00
parent b0a75384e9
commit b26638f946
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
3 changed files with 13 additions and 4 deletions

View File

@ -6,3 +6,8 @@ repos:
hooks:
- id: black
args: ['--target-version', 'py37', '--skip-string-normalization', '--line-length', '110']
- repo: https://github.com/PyCQA/isort
rev: 5.7.0
hooks:
- id: isort
args: ['--profile', 'black', '--line-length', '110']

6
README
View File

@ -36,7 +36,11 @@ black is used to format the code, using thoses parameters:
black --target-version py35 --skip-string-normalization --line-length 110
There is .pre-commit-config.yaml to use pre-commit to automatically run black
isort is used to format the imports, using those parameters:
isort --profile black --line-length 110
There is .pre-commit-config.yaml to use pre-commit to automatically run black and isort
before commits. (execute `pre-commit install` to install the git hook.)

View File

@ -1,5 +1,5 @@
[tox]
envlist = py3-django111-pg-black-coverage-pylint, py3-django22-pg
envlist = py3-django111-pg-codestyle-coverage-pylint, py3-django22-pg
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/chrono/{env:BRANCH_NAME:}
[testenv]
@ -32,10 +32,10 @@ deps =
django22: django>=2.2,<2.3
django111: djangorestframework<3.12.0
psycopg2-binary
pre-commit
codestyle: pre-commit
commands =
./getlasso3.sh
python3 setup.py compile_translations
py.test {env:COVERAGE:} {posargs:tests/}
pylint: ./pylint.sh chrono/
black: pre-commit run black --all-files --show-diff-on-failure
codestyle: pre-commit run --all-files --show-diff-on-failure