4_2-pre_commit-slides
4_2-pre_commit-slides
Pre-commit
1
20/10/2024
Configuration
(https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/)
A sample file
2
20/10/2024
3
20/10/2024
❔ Exercises
1. Install pre-commit
pip install pre-commit
2. Next create the sample file
pre-commit sample-config > .pre-commit-config.yaml
3. The sample file already contains 4 hooks. Make sure you understand
what each do and if you need them at all.
4
20/10/2024
6. Try adding at least another check from the base repository to your
.pre-commit-config.yaml file.
7. If you have learned about the linter ruff. ruff comes with its own
pre-commit hook. Try adding that to your .pre-commit-
config.yaml file and see what happens when you try to commit
files.
8. (Optional) Add more hooks to your .pre-commit-config.yaml.
9. Sometimes you are in a hurry, so make sure that you also can do
commits without running pre-commit e.g.
git commit -m <message> --no-verify
10.Finally, figure out how to disable pre-commit again (if you get tired
of it).
10
10