-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
style: add pre-commit and new checks #530
Conversation
1c65189
to
87f9599
Compare
I'm on board with this and agree with the changes overall, there are a lot of changes in this PR but they all seem to be small linty/style type stuff which is fine! However since it's a reasonable change to how our CI works (albeit not to the user, they simply run |
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
Are you planning to move this check to pre-commit.ci in a separate PR? Otherwise, we should probably switch to the pre-commit action for the lint
job. This speeds up CI by caching the pre-commit environments.
Edit: Actually, the lint step is surprisingly fast even without caching.
Happy to merge as is or do we want to change to the pre-commit action? |
No, that action is deprecated in favor of pre-commit.Ci. Someone with permissions will have to enable pre-commit.ci for the repo. |
Okay, sounds like that's best done under a new PR then |
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 don't have experience with pre-commit, but it seems like it will fit well with Nox!
Also, and sorry for my ignorance, but... will pre-commit do the changes for us, or it will just fail?
It will just fail. It effectively just runs all the linters specified in the config file. You can use it how we do here (by calling Some people (myself included) don't like the latter option as long running checks can interrupt your commit flow but it depends on what you have configured |
Does that imply that this PR leaves no easy way for a developer to run black and isort to make changes as the "blacken" session does now? |
I almost always run Pre-commit supports both changing checks (black, pyupgrade) as well as failing checks (flake8). The changing ones are better, since they can be fixed automatically by pre-commit.ci and pushed. |
BTW, I would suggest to add |
Sorry just re-read my reply and it wasn't too clear! As @henryiii said it can do both changing and non-changing fixes, my saying it will fail was confused by pre-commits commit hook functionality which would fail the commit even if it managed to change the code e.g. black, pyupgrade etc as you'd have to re-commit the changes. Looks like with |
838922d
to
38487da
Compare
Thank you @henryiii |
Adds pre-commit as a check-driver (in turn, driven by Nox), and adds some new checks - I added most of my favorites, figuring we could scale back or split up as needed.
shellcheck: looks for mistakes in shell scripts. Might not be needed, not sure if there are any shell scripts.Removes "nox -s blacken", since some checks modify in place anyway, and everything is in git.
I'll comment on the changes a bit inline.