Skip to content

Conversation

@mike-shvets
Copy link

@mike-shvets mike-shvets commented Feb 22, 2020

Note for the first PRs: PR should be merged by the author after approval, don't merge a PR if it is not yours, as the author may want to still do some tweaks (and maybe even request another review if those are major).

This commit adds support for local pre-commit automatic formatting.
Once you try to commit, yapf will check code quality and modify inplace files that are not compliant with the formatting rules. You will have to review the changes and include them in the commit.

You can bypass the hook by adding a flag: git commit --no-verify.

https://github.com/google/yapf/blob/master/plugins/pre-commit.sh

In order to add yapf pre-commit formatting, execute the following locally:

conda install yapf==0.28.0
cp tools/pre-commit.sh .git/hooks/pre-commit

Notes:

  • tmp.py had terrible formatting before I tried to commit. yapf fixes it to current form
  • I don't like that empty line at the end of file is missing, but that's minor. Is this PEP8?
  • If the repo is not going to be huge, we can just create a pre-push hook simply trying to yapf-format all the python files.

TODO:

  • remove tmp.py file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants