-
Notifications
You must be signed in to change notification settings - Fork 139
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 precommit and run precommit on all files #26
base: master
Are you sure you want to change the base?
Conversation
2 similar comments
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.
lgtm. often we add pre-commit run --all-files
to the tests somewhere which helps to make sure it doesn't regress, but it's up to you if you want to do that or not.
@@ -0,0 +1 @@ | |||
pre-commit==0.13.3 |
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'd probably call this file requirements-dev.txt
since you don't actually need pre-commit to be installed in production (and that's what requirements.txt
implies, even if you're not actually doing it in this case).
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.
Also, we usually don't pin specific versions for our dev dependencies, but that's totally up to you / the project's stance on that.
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.
Maybe adding something like the following in the README will actually add more visibility into Yelp's pre-commit project and provide a better understanding to the developer, rather than using a requirements.txt
file that might confuse collaborators :)
Collaborate
This project is using pre-commit to help the developer run pre-commit hooks easily, allowing to autoformat Python files, reorder the imports, and other various checks.
You can easily start using it via pip install pre-commit
.
Thoughts?
- repo: https://github.com/asottile/reorder_python_imports | ||
sha: v0.3.2 | ||
hooks: | ||
- id: reorder-python-imports |
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've been using isort for checking the import ordering: https://github.com/graphql-python/flask-graphql/blob/master/tox.ini#L30.
Also being used in the automatic linters in graphql-core
https://github.com/graphql-python/graphql-core/blob/master/bin/autolinter#L7, and graphene
https://github.com/graphql-python/graphene/blob/master/bin/autolinter#L7.
I kind of prefer it over render-python-imports
as it seems it does a smarter import grouping, not requiring a import statement per imported var.
If we could use isort
instead of render-python-imports
would be great! :)
Other than the comments, everything is looking great... thanks for the work @tomelm! :) |
Adds pre-commit and runs it on all the current files. I skipped a few validations so I'm not making too many big changes and also set the max-line-length to 120: