-
Notifications
You must be signed in to change notification settings - Fork 595
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
enable pre-commit #452
base: main
Are you sure you want to change the base?
enable pre-commit #452
Conversation
python-version: "3.12" | ||
|
||
# Setup venv | ||
- name: Setup venv + uv |
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.
pre-commit manages its own isolated venv, hence no more env management.
Also no need to install smolagents
for lint & formating, only pre-commit
and ruff
are needed
python-version: "3.10" # lower bound of the supported Python versions | ||
- uses: pre-commit/[email protected] |
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.
this action uses some caching under the hood, which speeds up ci actions
# Equivalent of "make quality" but step by step | ||
- run: uv run ruff check examples src tests utils # linter | ||
- run: uv run ruff format --check examples src tests utils # formatter | ||
- run: uv run python utils/check_tests_in_ci.py |
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.
Now a pre-commit
hook
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 would prefer to stay aligned with all the other huggingface open source libraries.
Additionally, previous attempt to use pre-commit had a compatibility issue with the CI quality job (handled with ruff), if I remember correctly.
Several other HF repos also seem to leverage pre-commit ( I feel your concern about compatibility issues, and that's actually what drives this PR: There are a few reasons
I am confident this will make the CI/CD more reliable, as well as |
This PR (re)enables pre-commit!
It has been discussed in a few issues & PRs now (#120, #119, #431), with good reason since it definitely improves the developer's workflow.
I've already ran into a few linting & formating issues myself with just a few PRs 😅
A few points:
pyproject.yaml
and.pre-commit-config.toml
, let's bump it from time to time or setup a dependabotruff xyz
since both rely on thepyproject.toml
for configurationpyproject.toml
so that the developer and its editor code editor can pick it up from the virtualenv and apply linting / formatingmake style
is redundant withmake quality
, so I deprecated it with a log for those who use it.pre-commit
hookI have another PR which adds a few needed additional rules to the linter but will lead to major merge conflicts across all opened PRs lol I'll open it in a second time.
Thanks for reviewing @aymeric-roucher @albertvillanova