You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -382,6 +382,57 @@ servers (LSP).
382
382
These configurations are provided as optional suggestions for convenience and do not imply official support or a
383
383
requirement to use specific tools.
384
384
385
+
### Pre-commit hook
386
+
387
+
#### General
388
+
389
+
The repository has a [prek](https://prek.j178.dev/) configuration, which allows for making sure that each commit created is compliant with the [code checking implemented in the CI](./.github/workflows/code-checkers.yml). This feature is **opt-in** and can be run manually.
390
+
391
+
This tool is configured via the [`.pre-commit-config.yaml`](./.pre-commit-config.yaml) file.
392
+
393
+
In order to run all the checks that the CI performs, you can simply run:
[prek](https://prek.j178.dev/) really shines once you start to run it automatically before each commit.
405
+
For this, we need to tell [prek](https://prek.j178.dev/) to install a [git hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) in our local repository:
406
+
407
+
```bash
408
+
$ uv run prek install
409
+
```
410
+
411
+
Note that you can easily remove this hook by running:
412
+
413
+
```bash
414
+
$ uv run prek uninstall
415
+
```
416
+
417
+
Once the hooks are in place, `git commit` will automatically:
418
+
- stash the changes that are not staged for this commit
419
+
- perform the `ruff`, `mypy`, `flake8` and `pyright` checks (unless the staged changes do not affect any python files, in which case the checks are skipped)
420
+
- re-apply the changes that were stashed
421
+
422
+
If the checks happen to fail, the commit is cancelled.
423
+
424
+
If for some reason, you are fine with a specific check failing, you can simply skip it with the `SKIP` environment variable.
425
+
You can also bypass all the hooks by adding the git option `--no-verify`, or the environment variable `GIT_NO_HOOKS=1`:
426
+
427
+
```bash
428
+
# Only skip the `flake8` hook
429
+
$ SKIP=flake8 git commit -m "my message"
430
+
# Do not run any hook before commit
431
+
$ git commit -m "my message" --no-verify
432
+
# Same thing, using an environment variable instead
433
+
$ GIT_NO_HOOKS=1 git commit -m "my message"
434
+
```
435
+
385
436
### [VSCodium](https://vscodium.com/)
386
437
387
438
A few plugins are recommended to properly report the diagnostics during the development:
0 commit comments