From d90612f43086f59968e6f49c6a06f4f9b2774604 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Tue, 30 Mar 2021 10:34:19 +0200 Subject: [PATCH 4/6] add isort configuration (#52457) --- .git-blame-ignore-revs | 2 ++ .pre-commit-config.yaml | 5 +++++ Jenkinsfile | 2 +- README | 4 ++++ tox.ini | 3 ++- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 348e62df..12746701 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,2 +1,4 @@ # misc: apply black 4bb33d3d3c62516cfdb1ff5bba9216936a07d368 +# misc: apply isort +ffb4193255e99b9c84131e1d409cba12782c8602 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a14705c7..be556e23 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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"] diff --git a/Jenkinsfile b/Jenkinsfile index 19ba570b..67bf5b55 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ pipeline { sh """ python3 -m venv ${env.TMPDIR}/venv/ ${env.TMPDIR}/venv/bin/pip install tox -PGPORT=`python -c 'import struct; import socket; s=socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0)); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'` pg_virtualenv -o fsync=off ${env.TMPDIR}/venv/bin/tox -rv -e rbac-py3-dj111,authentic-py3-dj111-drf39-black,authentic-py3-dj22-drf39,pylint""" +PGPORT=`python -c 'import struct; import socket; s=socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0)); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'` pg_virtualenv -o fsync=off ${env.TMPDIR}/venv/bin/tox -rv -e rbac-py3-dj111,authentic-py3-dj111-drf39-black-isort,authentic-py3-dj22-drf39,pylint""" } post { always { diff --git a/README b/README index 1a8203b4..5642d7c7 100644 --- a/README +++ b/README @@ -78,6 +78,10 @@ black is used to format the code, using thoses parameters: 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.) +isort is used to format the imports, using those parameter: + + isort --force-single-line-imports --line-length 110 + Support ======= diff --git a/tox.ini b/tox.ini index f5237aa5..f3341c9b 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ [tox] toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/authentic/ envlist = - authentic-py3-dj111-drf39-black + authentic-py3-dj111-drf39-black-isort authentic-py3-dj22-drf39 [tox:jenkins] @@ -85,6 +85,7 @@ commands = authentic: ./check-migrations.sh rbac,authentic: py.test {env:PYTESTOPTIONS:} {env:FAST:} {env:REUSEDB:} {env:COVERAGE:} {env:JUNIT:} {env:SW:} {posargs:{env:TESTS} --random-group} black: pre-commit run black --all-files --show-diff-on-failure + isort: pre-commit run isort --all-files --show-diff-on-failure [testenv:pylint] basepython = python2.7 -- 2.20.1