Open lukpueh opened 5 months ago
without understanding pre-commit much, how about this:
tox -e lint
fast (aka use ruff)tox -e lint
in a commit hookI think this would explicitly not use pre-commit itself though.
The difference would be that tox -e lint
doesn't reformat your code.
A tox -e reformat
command would be nice to have anyway maybe
I'm always pro lighter toolchain.
With Ruff as our linter now we can add tox -e reformat
with ruff format {[testenv:lint]lint_dirs}
in tox.ini. We could also add this immediately on tox -e lint
by removing the --diff
flag on ruff format, this would depend if the suggested reformatting changes should be reviewed first before being performed.
In my experience, reformatting and format checking + linting are usually separated. But I suppose we can combine them, now that both of them are so fast. The important thing is that tox -e lint
fails CI, if the format is incorrect. What do others think?
I think the autofix/autoformat feature is not a must-have but I'm not complaining if it's there. I wouldn't add it to lint
itself though -- it feels like there should be a way to "just test", not fix.
In python-tuf I added tox -e fix
which ends up running something like
ruff check --fix <DIRS>
ruff format <DIRS>
I wouldn't add it to lint itself though -- it feels like there should be a way to "just test", not fix.
Agreed. Not so much because I want to be able just test, but more because I don't want change anyone's sources when they don't expect it.
Plugins (most notably isort and black) in
.pre-commit-config.yaml
are not updated by Dependabot and thus prone to become out of sync with the same dev tools used by tox (also see discussion with @jku in #582).We should find a way to keep them in-sync.