-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Add pre commit hooks #1915
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
Add pre commit hooks #1915
Conversation
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
75974a0 to
59d4f30
Compare
|
Output from jenkins |
|
@dnephin 💖 look at those ordered imports!!! HAPPY! Interesting that it's broken up multi imports and done them as individual separate imports, I've not seen it done that way before and I'm not sure I particularly like it but I can totally forgive it for the clarity it brings in ordering. Brilliant. LGTM 👍 |
|
_Nice._ This is going to break a lot of open PRs' builds, but it's got to be done at some point. LGTM |
|
Thanks! The import ordering I think originally comes from https://code.google.com/p/soc/wiki/PythonStyleGuide#Imports_grouping_and_order I just realized I should probably also mention this in the contributing guide |
|
I'm confused, it was in it's own commit (59d4f30)
It is unfortunate that this will cause a lot of conflicts, but it's a one-time cost. Going forward it should actually prevent more conflicts. The pre-commit hooks for ordering and flake8 should make it easy to resolve. You can basically just accept both versions of the conflict, then run pre-commit, and it will tell you which are duplicate, and order the rest.
Having an automated way of enforcing it makes it really easy to follow, you just run the commit hooks and it ensures you're following the standard. The documentation is covered by pep8. I've added the docs for using these hooks in this PR #1918. Sorry they weren't included immediately. If you think they need more details, please comment on that PR.
Totally agree, that's what we're doing here! The automated checks run as part of the CI build.
If you run the steps documented here #1918 it will correct the issue for you. Again, sorry the docs came after the initial PR. |
This adds http://pre-commit.com as a linting step, in place of just flake8 (flake8 is still there as one of the steps).
All checks will be run as part of CI, but they also get installed as a pre-commit hook in your local repo. So instead of waiting for the build to run (and fail), you get notified of errors before you can even commit.
Docs for the hooks are here: https://github.com/pre-commit/pre-commit-hooks and https://github.com/asottile/reorder_python_imports
The second commit is all the files with fixed whitespace and import ordering.
cc @mnowster since you expressed some interest in keeping imports sorted