A pre-commit hook to format python code files. The pre-commit.sh file was totally copied from google yapf project.
You can use it with pre-commit or in a naive Git hooks way.
- create a file named .pre-commit-config.yaml under the root of your git project.
- Add the follow lines to your .pre-commit-config.yaml
repos:
- repo: https://github.com/chengzhang/google-python-style-precommit-hook.git
rev: 0f10b46c22c8c389ce6bc16d71a18c03c74d160c
hooks:
- id: google-python-style
- run
pre-commit install
# From the root of your git project.
curl -o pre-commit.sh https://raw.githubusercontent.com/chengzhang/google-python-style-precommit-hook/main/pre-commit.sh
chmod a+x pre-commit.sh
mv pre-commit.sh .git/hooks/pre-commit