Skip to content

Commit

Permalink
Add isort to CI and pre-commit (home-assistant#29739)
Browse files Browse the repository at this point in the history
* add isort to CI and pre-commit

* disable wrong-import-order in pylintrc

* ✏️ Tweak


Co-authored-by: Franck Nijhof <[email protected]>
  • Loading branch information
basnijholt and frenck committed Dec 12, 2019
1 parent 7d68e88 commit c58c10a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .pre-commit-config-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions azure-pipelines-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 3 additions & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions requirements_test_pre_commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c58c10a

Please sign in to comment.