diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a14705c76..995a5283a 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: ['--force-single-line-imports', '--line-length', '110'] diff --git a/Jenkinsfile b/Jenkinsfile index 30ef7882d..ec6e83331 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,11 +9,11 @@ pipeline { stage('Unit tests django 1.11') { agent any steps { - sh 'tox -rv -e py3-django111-black-pylint-coverage' + sh 'tox -rv -e py3-django111-codestyle-pylint-coverage' } post { always { - stash includes:'junit-py3-django111-black-pylint-coverage.xml', name: 'django111' + stash includes:'junit-py3-django111-codestyle-pylint-coverage.xml', name: 'django111' script { utils = new Utils() utils.publish_coverage('coverage.xml') diff --git a/README b/README index edce305cd..89b82405e 100644 --- a/README +++ b/README @@ -39,6 +39,10 @@ black is used to format the code, using thoses parameters: black --target-version py37 --skip-string-normalization --line-length 110 +isort is used to format the imports, using those parameters: + + isort --force-single-line-imports --line-length 110 + 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.) diff --git a/tox.ini b/tox.ini index 6d2050a66..54e1b1fd4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/wcs/{env:BRANCH_NAME:main}/{env:EXECUTOR_NUMBER:} -envlist = py3-django111-black-pylint-coverage, py3-django22 +envlist = py3-django111-codestyle-pylint-coverage, py3-django22 [testenv] sitepackages = true @@ -46,4 +46,4 @@ deps = commands = py.test -v {env:COVERAGE:} --junitxml=junit-{envname}.xml {posargs:tests/} pylint: ./pylint.sh wcs/ - black: pre-commit run black --all-files --show-diff-on-failure + codestyle: pre-commit run --all-files --show-diff-on-failure