-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
Workflow: recommend pre-commit for code checks #23616
Comments
+1 on this, but I'd just add things that are immediate or almost immediate to be checked (e.g. It'll be some work to check things mainly based on the diffs so they are fast (I'm thinking for example in docstring changes), but if we manage to do it, I think it should make our life, and contributors life much easier. |
I don’t know exactly what flake8 is doing, but it’s been fast in my experience. Probably just flake8ing the files that changed.
You can also skip checks with the right flags.
…________________________________
From: Marc Garcia <[email protected]>
Sent: Saturday, November 10, 2018 6:35:09 PM
To: pandas-dev/pandas
Cc: Tom Augspurger; Author
Subject: Re: [pandas-dev/pandas] Workflow: recommend pre-commit for code checks (#23616)
+1 on this, but I'd just add things that are immediate or almost immediate to be checked (e.g. git diff upstream/master -u -- "*.py" | flake8 --diff, which wouldn't be necessary in the PR template).
It'll be some work to check things mainly based on the diffs so they are fast (I'm thinking for example in docstring changes), but if we manage to do it, I think it should make our life, and contributors life much easier.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#23616 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABQHIl8gNU_ReAUCXeJ-Yn7HNjx4Inqeks5ut3C9gaJpZM4YYK1m>.
|
btw i find that putting things in the Makefile is nice for interactive development eg make lint-diff |
+1 from me as well. Good sanity checks. |
@TomAugspurger in #23707:
I'm quite strongly against precommit hooks (esp. modifying content in place). I tried them myself recently to deal with ipython notebooks, but the problem is that, generally speaking:
I would say that (was gonna comment the same in #23658):
|
there's a difference between committing and pushing (not every commit
needs the equivalent of a lint check)
Hopefully these checks are fast enough that they don't slow you down. I
haven't found them to be troublesome.
modifying inplace is *bad*, and not just in situations where commits are
aborted (empty commit), etc
The isort hook does modify files in place, but does not stage the changes.
I've found the workflow of
```
git add .
git commit -m ...
# isort failure
git diff # inspect what isort did
git add .
git commit -m ...
```
to be quite nice.
git can't enforce people using the hooks
We can't enforce that contributors follow the issue template either :)
We'll still have the CI to enforce things.
This is just to ease the annoying push, wait for CI, see small linting
mistake cycle.
Aside from the fact that installing githooks is another barrier to entry
for new developers.
I found pre-commit to be pretty painless. Have you used it?
pre-commit does support pre-push hooks. If we like this, we can start
adding some more expensive checks as pre-push
checks to the config we distribute.
|
@TomAugspurger this can be closed now after #27233 ? |
Yep, thanks. |
pre-commit is a library for running pre-commit hooks (actually does more that just pre-commit). Adding additional code checks is likely to annoy first-time contributors (isort); we can use tools to avoid that.
I've been using this
.pre-commit-config.yaml
With that in the root of my directory, every time I
git commit
, those code checks are run.Suppose I have an out-of-order import, and go to commit my changes
The hook modified the file in place. I can check the status / diff from HEAD
add them, and commit again
before pushing.
What are people's thoughts. I think we can distribute a
.pre-commit-config.yaml
with the git repo. If pre-commit isn't installed, I assume nothing will happen.The text was updated successfully, but these errors were encountered: