- Install pre-commit:
pip install pre-commit
will install pre-commit - Add pre-commit to requirements.txt
pip freeze | grep pre-commit >> requirements.txt
- Define
.pre-commit-config.yaml
with the hooks you want to include. - Execute
pre-commit install
to install git hooks in your .git/ directory similar to that of husky.
Black for formatting (similar to prettier in js) and flake8 for PEP8 compliance (similar to eslint for node apps)
View .pre-commit-config.yaml
for an example of the pre-commit config that will be installed.
View pyproject.toml
for an example of a simple Black config.
View .flake8
for the flake8 config.
This is a great article that pretty much sets up a project the same way.