From 6c6d7bac407d7ff697dc54c63723c1b051d24a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= Date: Tue, 6 Apr 2021 21:28:51 +0200 Subject: [PATCH] misc: add isort (#52797) --- .pre-commit-config.yaml | 5 +++++ README | 6 +++++- tox.ini | 6 +++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a14705c7..c6a0c576 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', '--line-length', '110'] diff --git a/README b/README index 91d2f16c..cc7bb4fa 100644 --- a/README +++ b/README @@ -96,7 +96,11 @@ black is used to format the code, using thoses parameters: black --target-version py37 --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.) diff --git a/tox.ini b/tox.ini index e15c35f4..3d78ca1d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/combo/{env:BRANCH_NAME:} -envlist = coverage-py3-django111-black-pylint-{sqlite,pg},py3-django22-pg +envlist = coverage-py3-django111-codestyle-pylint-{sqlite,pg},py3-django22-pg [testenv] usedevelop = True @@ -32,11 +32,11 @@ deps = vobject django-ratelimit<3 git+https://git.entrouvert.org/debian/django-ckeditor.git - black: pre-commit + pre-commit uwsgidecorators commands = ./getlasso3.sh python manage.py compilemessages py.test {env:COVERAGE:} {posargs: --junitxml=junit-{envname}.xml tests/} pylint: ./pylint.sh combo/ - black: pre-commit run black --all-files --show-diff-on-failure + codestyle: pre-commit run --all-files --show-diff-on-failure