Skip to content
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

Suggestion: add git-hook hook for pre-commit #384

Open
machinekoder opened this issue Mar 21, 2023 · 1 comment
Open

Suggestion: add git-hook hook for pre-commit #384

machinekoder opened this issue Mar 21, 2023 · 1 comment

Comments

@machinekoder
Copy link
Contributor

machinekoder commented Mar 21, 2023

Since a run of pre-commit is required before creating a PR, it would be reasonable to add pre-commit as git-hook. We use this in our development repos and have very good experience since it ensures everyone is actually running pre-commit.

At the moment, it looks like only part of the repo is actually conveying the code standards enforced by the pre-commit tasks, as can be verified by running pre-commit run --all-files. Running pre-commit in the CI might help-as well.

If you think that sounds reasonable, I'd be happy to create a PR.

@jonathanagustin
Copy link
Contributor

jonathanagustin commented Mar 21, 2023

I think pre-commit install will install it as an actual git-hook, but I see your point that it is not committed into the repo by default.

There may be some intention or concern to not do so because the comments mention that it is slightly dangerous:

# this is slightly dangerous because python imports have side effects
# and this tool removes unused imports, which may be providing
# necessary side effects for the code to run
- repo: https://github.com/PyCQA/autoflake
rev: v1.6.1
hooks:
- id: autoflake
args:
- "--in-place"
- "--expand-star-imports"
- "--remove-duplicate-keys"
- "--remove-unused-variables"
- "--remove-all-unused-imports"
exclude: "evals/__init__.py"

A manual run adds a kind of self-check to confirm the existence of unused-in-file imports. I see this visual check as a good thing in library imports like __init__.py (which is excluded in the code above) where the intention is to expose functionality but not necessarily use them within the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants