Hello everyone,

*TL;DR: Please switch from pre-commit to prek for your local development,
please, at your earliest convenience.*

Following the discussion in
https://lists.apache.org/thread/mb73g4rz56n5l0gjyzm9jzolnkkc6o5c I just
merged https://github.com/apache/airflow/pull/54258 that switches
`pre-commit` we used for several years to `prek` in CI and breeze. The
`prek` tool is faster, leaner and has already more features we wanted to
have in the last few years for pre-commit and we had to add them in breeze
- a lot of them added in a matter of last few days in the course of
collaboration with the author.

In short what everyone should do now (at earliest convenience):

*uv tool install prek*
*prek install -f*

That's all you need to do, to switch.

The documentation on how to use`prek` is updated in
https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst

Here is the short(?) recap:

*On running prek:*

Running pre-commit hooks is as easy as running `*prek*`. That should work
in most cases out-of-the-box (no need even to add `run`). If you have
`prek` installed with `prek install` - it will just run automatically when
you commit your code.

We removed `breeze static-checks` because `prek` implements practically all
the functionality we had to add in breeze in order to compensate for lack
of cooperation from pre-commit maintainers (auto-commit, --last-commit,
--only-my-changes . When you run `breeze static check` you will see a
removal message and instructions on how to switch to prek.

One notable change is that breeze's `--only-my-changes ` can be achieved
with `*prek --from-ref main*` (and it also works now for past branches if
you are working on PR  that was branched from v3-0-test for example (`prek
--from-ref v3-0-test` )

*On why we switched:*

The `prek` tool is written in Rust and *Jo* (sorry I misspelled your name
before): https://github.com/j178  -  has gone above and beyond and
accommodated all our comments and issues we found during the development.
Including the likely toughest decision ever on changing name from prefligit
to prek. A lot of people helped to test it and reported (and helped fixing
some initial issue) and with 0.0.26 released yesterday, `prek` seems to be
ready to be used in our CI and local development. The last issue that was
blocker, was with pseudo-terminal allocation and colors in the failure
output from ruff and others. It is a pleasure to work with Jo (and I
started to learn a bit rust while doing so  :D). Big thanks to Jo for the
dedication and persistence and "user-focused-thinking". Thanks to Ash for
all the encouragement for Jo as well and all the initial push of us in the
"prefligit" direction.

There are more things to come and we have a way to force a minimum version
of prek when we start using the upcoming versions (`minimum_prek_version`
is now set to 0.0.26).

*On pre-commit compatibility:*

For now, the .pre-commit-config.yaml is compatible with the latest
pre-commit (it will just raise a warning now as prek_minimum_version is
unknown to it). You can continue using `pre-commit` for a while - but this
warning will remind you to switch to `prek` at earliest convenience. At
some point of time when `prek` will have better monorepo support we will
likely split our pre-commit config to multiple files at which point we will
only support `prek` (unless pre-commit will catch up and implement
compatible feature, but I have no high hopes for that)

*If you have errors:*

Of course we should be watching for any teething issues - so please report
any issues in #contributors or #internal-airflow-ci-cd Slack channels.

If needs be - you can switch back to pre-commit by:

*prek uninstall*
*pre-commit install *

J.

Reply via email to