Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add pre-commit #10

Merged
merged 1 commit into from
Dec 13, 2024
Merged

chore: add pre-commit #10

merged 1 commit into from
Dec 13, 2024

Conversation

langenhagen
Copy link
Collaborator

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:

pre-commmt install      # install the hooks into this mf
pre-commit run --all    # run the checks against all files in the repo
git commit --no-verify  # --no-verify: bypass pre-commit checks

See: https://pre-commit.com/

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:

    pre-commmt install      # install the hooks into this mf
    pre-commit run --all    # run the checks against all files in the repo
    git commit --no-verify  # --no-verify: bypass pre-commit checks

See: https://pre-commit.com/
@langenhagen langenhagen changed the title chore: add pre-commit chore: add pre-commit Dec 13, 2024
@langenhagen langenhagen merged commit 44e7b6d into main Dec 13, 2024
2 of 3 checks passed
@biering biering deleted the add-pre-commit branch December 16, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant