-
-
Notifications
You must be signed in to change notification settings - Fork 35k
Add isort to CI and pre-commit #29739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Somehow I forgot these. See home-assistant#29739
I think that need a rebase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fully support this, but the hook config needs to be added to .pre-commit-config-all.yaml
too.
@scop, done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pylint also checks order of imports. It uses isort internally so presumably there's at least some compatibility, but it does something more besides just running isort and I'm not sure if it considers our isort config, and with this change those checks are redundant anyway. So I think it would be a good idea to disable wrong-import-order
in pylintrc
as part of this change. (Maybe doing that might make it a bit faster, or maybe not.)
@scop, good point. edit: I searched for the occurrences of I have added it to |
I just wondered if our auto-generated files actually generate valid imports... |
What files do you mean, specifically? |
7c6d66d
to
a197e82
Compare
Awesome job @basnijholt! 🥇 |
You too @frenck, thanks for reviewing the 147 PRs so quickly! 😄 |
Description:
🎉 All PRs have been merged!
This adds
isort
to the CI andpre-commit
. I think it is smart to reduce the number of style changes even further, in that waygit blame
will become even more useful.isort
will enforce a consistent import order, and using the settings I added in thepre-commit
config, it plays well withblack
(source).I have opened PRs for each component that involves changes to >= 3. I've done this because I think it would be too big of a change too sudden otherwise (as it involves >1000 files which is hard to review).
All changes to components that involve <=2 files, I have partitioned into PRs with the starting letter.
Then per main folder, I have another PR (as discussed with @frenck).
I have opened these PRs:
These are for PRs of components starting with:
And the non-components:
homeassistant
(Sort imports according to PEP8 for 'homeassistant' folder #29789)script
(Sort imports according to PEP8 for 'script' #29790)tests
(Sort imports according to PEP8 for 'tests' #29791)setup.py
(Sort imports according to PEP8 for 'setup.py' #29792)Checklist:
tox
. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
python3 -m script.hassfest
.requirements_all.txt
by runningpython3 -m script.gen_requirements_all
..coveragerc
.If the code does not interact with devices: