astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
28.47k stars 808 forks source link

Discussion: Re-implement pre-commit in rust (in `uv`)? #8131

Open phitoduck opened 1 month ago

phitoduck commented 1 month ago

pre-commit is a great tool, but it has some weaknesses.

But seriously, would it make sense to bring pre-commit into uv or otherwise into ruff or it's own project?

gaborbernat commented 1 month ago

FYI there is https://pypi.org/project/pre-commit-uv but obviously could be built into uv though pre-commit supports other languages (such as node, r, etc), so a full reimplementation would be more difficult.

Avasam commented 1 month ago

For me the real strength of pre-commit (the tool, not the git hook) comes from its ci integration (pre-commit.ci) that provides autofixing. It does however have some things its lacking in. Like a 250MiB download limit (which makes it near impossible to use large/complex ESLint configs). The fact it has to pin exact versions, which duplicates versions defined in code. The autoupdate PRs not being possible to disable. Blocks all downloads at runtime (so no referencing online configs). Monorepo support could be better. And probably more.

On the CI side, it might be worth considering a GitHub action like https://github.com/EndBug/add-and-commit or https://github.com/stefanzweifel/git-auto-commit-action instead . Just run your formatters and autofixers as usual, then autocommit them. I'm personally looking for something like this since I'm also hitting pre-commit limitations with dprint and eslint (on top of the version lock annoyance), but haven't yet tested or vetted any. At work I wrote our own Azure DevOps extension for it.

j178 commented 2 weeks ago

Hi, I'm working on a Rust implementation of the pre-commit tool: pre-commit-rs. It's still in the early stages, with only a few features implemented and not yet ready for production use. If anyone is interested, please give it a try!