-
-
Notifications
You must be signed in to change notification settings - Fork 329
style: add ruff and black to pre-commit #1459
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
😵💫 it looks like the code gets automatically styled by github actions after modifying the pre-commit config, so it's not possible to separate the config changes from the styling itself in separate PRs. |
Codecov Report
@@ Coverage Diff @@
## main #1459 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 37 37
Lines 14723 14723
=========================================
Hits 14723 14723
|
I'm not sure what to think of the pre-commit-ci bot. I feel like linting should be part of the checking process, not automatically applied via automated commits. At least for this PR, automatically running pre-commit is very wrong, because I deliberately did not commit the files that the bot modified. edit: it also seems like the bot is not running pre-commit in the same way as in my local environment. When I execute local pre commit run
|
@rabernat any thoughts on how to proceed here? Because of the pre-commit-ci bot, there's no way to cleanly separate the styling config changes from the styling itself in git history if we squash the commits in this PR. We could just not squash the commits, and I then exempt the CI bot's commit from git blame? |
and, you can use |
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, you don't actually need a separate PR to preserve git blame. You could do something like -
- first commit - adding the new pre-commit, new config, etc.
- second commit - the changes introduced by the new pre-commit (let the bot commit in the PR or fix them manually by
pre-commit run --all-files
) - third commit - update
.git-blame-ignore-revs
with the commit hash of the second commit (and probably a comment explaining why the commit is ignored)
thanks for the pointers @Saransh-cpp! Do you have any idea why the bot is running pre-commit successfully, while my local runs produce a lot of errors? |
The bot does show a few errors too, here - https://results.pre-commit.ci/run/github/48049137/1689170255.FwDDg2OQSPy25V6evetUAQ. The bot just fixes everything that it can fix and then leaves the things that have to be manually fixed. If there are things that it cannot fix, it errors out, and the logs are available in the GH Actions section of PRs. Regarding #1460 (comment): Linting is also a part of the checks. If you scroll down in the GH Actions or the checks section of this PR, you'll find a |
but this is confusing, (and maybe i just don't understand pre-commit well enough), because I thought the entire point of pre-commit hooks were that they block you from committing if they fail. So it's not obvious why the bot is committing against my branch when the pre-commit hooks are failing. |
|
the bot and I are not off to a good start, but maybe i will change my mind about it. In the meantime, I will try to work around it. thanks for your help so far! |
95fa611
to
9c8137a
Compare
@Saransh-cpp I'm trying to avoid triggering this bot. Can you explain what I did wrong in my commit message?
|
I'm locking this branch so that the bot cannot make any more changes. |
499f45e
to
2d9e687
Compare
@rabernat I think this is ready. sorry for all the noise! it looks like the repo is configured to only allow PRs via the squash and merge strategy, which will obviate the addition to |
I am absolutely fine with that. However, I'd like to check with @joshmoore before changing the repo settings. |
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.
Overall this looks good to me. It's hard to actually "review" a PR that touches nearly every file in the code base. My impression is that the pre-commit config looks right and the CI is working. The formatting changes all seem reasonable.
it would be great if someone with deeper git knowledge (e.g. @jakirkham) to weigh in on what this will do to our commit log. I don't foresee any problems, but I could be missing something.
Thanks so much @d-v-b for taking on this important chore!
Here are my thoughts:
|
Are there any specific PRs you have in mind? My sense is that there are not a lot of active PRs right now, which might make it a good time to do this change. It will never be trivial, but we have to rip the bandaid somehow. |
Not particularly, no. But I also haven't reviewed in a while. If you guys want to run with this, I'd ask you to take responsibility for one of:
cc: @jakirkham |
…into ruff_black_prelude
@rabernat conflicts are resolved. |
For some reason codedov status has not been submitted. It would be great to have that go green before merging. Does anyone know what's going on? It looks like codecov has not received a payload for d27a6aa. https://app.codecov.io/gh/zarr-developers/zarr-python/pull/1459 Edit: seeing this in the workflow logs
|
Maybe I don't understand the issue here -- won't authors of active PRs be prompted to pull in the latest version of |
I've spent a good deal of time (previously) going through PRs and trying to keep them up-to-date. I don't necessarily expect you guys to do that, but I do think communicating what's going on would be a kind thing to do for these other contributors. Not everyone will be using pre-commit locally and if the automated check is disabled there won't be any indication of this new requirement. |
I'm happy to go through and update extant PRs as needed. |
Without squashing to simplify the history management.
This PR is a prelude to reformatting the codebase with
ruff
andblack
linters. .pre-commit-config.yaml
andpyproject.toml
have been modified to add + configureruff
andblack
(and removeflake8
).A subsequent PR will contain the styling changes.
TODO: