Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add the
pre-commit
system to conveniently manage sophisticated git pre-commit hooks for quick local checks fore pushing. Upshot is, you don't have to wait for CI to tell you that e.g. formatting or typing is wrong.The
pre-commit
project provides a fairly easy way to maintain several different hooks. You can use standard checks, write your own or use community-driven checks that are usually hosted on GitHub and configure them to your gusto.I added simple ruff-related checks, taken from:
https://github.com/astral-sh/ruff-pre-commit
I also enabled 2 standard checks, one for trailing spaces and another one for JSON-verification.
We can add type checking with mypy as well, but that seems not to be set up properly atm.
Usually, hooks work on the changeset/diffs of the commit, although that depends on the individual hook. Some might work across entire files or the entire repo. You can configure most of them.
Note that pre-commit hooks do bring their own dependencies, managed in a separate venv, that is not the project's actual venv. This way, depencencies and dependency version in the hooks may deviate from the actual project's setup.
Useful commands:
See: https://pre-commit.com/