misc: add isort (#52937)

This commit is contained in:
Nicolas Roche 2021-04-12 09:23:11 +02:00
parent dceb73599a
commit 5fade419f7
3 changed files with 17 additions and 3 deletions

View File

@ -6,3 +6,8 @@ repos:
hooks: hooks:
- id: black - id: black
args: ['--target-version', 'py37', '--skip-string-normalization', '--line-length', '110'] 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']

9
README
View File

@ -62,9 +62,18 @@ black is used to format the code, using thoses parameters:
black --target-version py37 --skip-string-normalization --line-length 110 black --target-version py37 --skip-string-normalization --line-length 110
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 There is .pre-commit-config.yaml to use pre-commit to automatically run black
before commits. (execute `pre-commit install` to install the git hook.) before commits. (execute `pre-commit install` to install the git hook.)
The .git-blame-ignore-revs file could be used to hide the related
changes into the sources:
git blame --ignore-revs-file .git-blame-ignore-revs
Tests Tests
----- -----

View File

@ -1,6 +1,6 @@
[tox] [tox]
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/passerelle/{env:BRANCH_NAME:} toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/passerelle/{env:BRANCH_NAME:}
envlist = py3-django111-black-coverage,py3-django22 envlist = py3-django111-codestyle-coverage,py3-django22
[testenv] [testenv]
usedevelop = True usedevelop = True
@ -37,12 +37,12 @@ deps =
django-ratelimit django-ratelimit
pyquery pyquery
zeep<3.3 zeep<3.3
black: pre-commit codestyle: pre-commit
commands = commands =
./get_wcs.sh ./get_wcs.sh
py.test {posargs: {env:FAST:} {env:COVERAGE:} {env:JUNIT:} tests/} py.test {posargs: {env:FAST:} {env:COVERAGE:} {env:JUNIT:} tests/}
coverage: ./pylint.sh passerelle/ coverage: ./pylint.sh passerelle/
black: pre-commit run black --all-files --show-diff-on-failure codestyle: pre-commit run --all-files --show-diff-on-failure
[pytest] [pytest]
filterwarnings = default filterwarnings = default