You might be interested in pre-commit which does exactly that!
https://pre-commit.com/
It probably will also support Ruff if it doesn't already.
It probably will also support Ruff if it doesn't already.
Still, I want some things to run more often than commit, such as pyflakes.