diff --git a/.pre-commit-config-all.yaml b/.pre-commit-config-all.yaml index cb01bff85cb0843e6cd324b6ae9435253ea6cb8b..ec9492e0210d9eeb1e5f19e908fc5ff4dbc42cb0 100644 --- a/.pre-commit-config-all.yaml +++ b/.pre-commit-config-all.yaml @@ -35,6 +35,10 @@ repos: - --format=custom - --configfile=tests/bandit.yaml files: ^(homeassistant|script|tests)/.+\.py$ +- repo: https://github.com/pre-commit/mirrors-isort + rev: v4.3.21 + hooks: + - id: isort # Using a local "system" mypy instead of the mypy hook, because its # results depend on what is installed. And the mypy hook runs in a # virtualenv of its own, meaning we'd need to install and maintain diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e6f37ae635592984f31d2e05f963b3205054a47d..23d1d9c73f9cf3cd0d16c275371024509db5a8c3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,3 +31,7 @@ repos: - --format=custom - --configfile=tests/bandit.yaml files: ^(homeassistant|script|tests)/.+\.py$ +- repo: https://github.com/pre-commit/mirrors-isort + rev: v4.3.21 + hooks: + - id: isort diff --git a/azure-pipelines-ci.yml b/azure-pipelines-ci.yml index cbad0c9af08a1cadbd045211636a60579a804e4e..5a289cbbc70c2a307235912235c0c45262e4d697 100644 --- a/azure-pipelines-ci.yml +++ b/azure-pipelines-ci.yml @@ -54,6 +54,10 @@ stages: . venv/bin/activate pre-commit run bandit --all-files displayName: 'Run bandit' + - script: | + . venv/bin/activate + pre-commit run isort --all-files + displayName: 'Run isort' - job: 'Validate' pool: vmImage: 'ubuntu-latest' diff --git a/pylintrc b/pylintrc index 3235d583865a8bd8d37090431486fc3c765a3ad2..0ffbb138f9e976372cd77ea315466e08d1c2f7a1 100644 --- a/pylintrc +++ b/pylintrc @@ -25,6 +25,7 @@ good-names=id,i,j,k,ex,Run,_,fp # unnecessary-pass - readability for functions which only contain pass # import-outside-toplevel - TODO # too-many-ancestors - it's too strict. +# wrong-import-order - isort guards this disable= format, abstract-class-little-used, @@ -49,7 +50,8 @@ disable= too-many-statements, too-many-boolean-expressions, unnecessary-pass, - unused-argument + unused-argument, + wrong-import-order enable= use-symbolic-message-instead diff --git a/requirements_test_pre_commit.txt b/requirements_test_pre_commit.txt index 14b866c70349af3a2057648c9400f27fcf7d5bd7..7a20962ff7cb0769b7ebcc3c29cd12be4dbb45f7 100644 --- a/requirements_test_pre_commit.txt +++ b/requirements_test_pre_commit.txt @@ -4,4 +4,5 @@ bandit==1.6.2 black==19.10b0 flake8-docstrings==1.5.0 flake8==3.7.9 +isort==v4.3.21 pydocstyle==5.0.1