A control quality to deliver clean code for small python projects with pre-commit.
-
Install quality control tools in requeriments-dev.txt
pip install -r requirements-dev.txt
-
Add a pre-commit configuration, create a file named .pre-commit-config.yaml
-
Install the git hook scripts to set up the git hook scripts
pre-commit install
-
(optional) Run against all the files
It's usually a good idea to run the hooks against all of the files when adding new hooks (usually pre-commit will only run on the changed files during git hooks) and check if the new hooks is working
pre-commit run --all-files
-
Once pre-commit is configured will run automaticaly all quality control test test [hooks] and will not permit to run
git commit -m 'mesage'if you not correct all errors and warnings. When you correct a script file. You should save changes and run againgit add .andgit commit -m 'mesage'.