-
Notifications
You must be signed in to change notification settings - Fork 0
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
Adding pre-commit hook #27
Conversation
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.
Hi @surbhigoel77, I think we talked about this a few times and discussed how a pre-commit workflow may be useful for those with good SE skills, but can be a burden or deterrent for those who are not so familiar with these concepts.
There is also the fact that it changes commit history on the remote, not local, easily leading to divergent histories.
My recollection was that we decided not to implement pre-commit for this project, but perhaps there was a discussion with @TomMelt or the collaborators that I missed.
Thanks for your comments @jatkinson1000. We (you and me) had a conversation on slack a couple of weeks back about including some CI in the project (not Github actions). So, I included running ruff as a pre-commit hook. The user doesn't have to do anything manually, other than correcting some minor formatting issues that ruff highlights at the time of committing changes. We can skip it if you suggest so. |
@jatkinson1000 , there might be some confusion here. I might be wrong, but I think this is just a pre-commit hook. @surbhigoel77 , am I right in thinking that this just runs locally on the users computer, like this. That is, can you confirm that it does not run on GitHub as an action. It might be a good idea @surbhigoel77 (assuming I understood correctly) to provide some instructions on how to setup/install the pre-commit hook and how to run it... and maybe also expected output 👍 |
@TomMelt you are right , it's a hook that runs locally. I will update the |
Ahh, but I think it does both. It also looks like it does automatically format the code... Or am I mistaken 😕 ? Can you confirm what this workflow does. |
Wait ... sorry my bad... the lint CI already existed before this PR. It is this file |
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.
Thanks @surbhigoel77
Couple of comments:
- Using zsh I had to do
pip install '.[pre-commit]'
to escape the square brackets. Might be worth pointing this out as quite a few people are on mac. See https://stackoverflow.com/a/30539963 - I did , then
pip install .[pre-commit]
which performs the ruff check, but then if I want to use ruff it was not installed. Perhaps ruff should be added as a dependency to the[pre-commit]
option?
Otherwise looks good.
@jatkinson1000 I have updated the Hence the same commands can be used by both Mac and non-mac users |
I just did a clean install and ran:
running
and running Please can you check this in a clean virtual environment so we can see if it is just my machine? |
Ah, OK, I think that works, and avoids the zsh/mac users issue. So perhaps we need to point that out or explain how they can get ruff in their local install. It's tricky to explain in words here are there are overlapping things, so let me know if you want to discuss. |
@jatkinson1000 I have added a |
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.
Thanks @surbhigoel77 This all seems sensible as discussed in-person.
pre-commit-config.yaml
with ruff as a pre-commit hook.pyproject.toml
to installpre-commit
as a dependency.README.md
with installation instructions forpre-commit
package