Created by: reyoung
Use a python package pre-commit
to manage git pre-commit
hooks when developing Paddle.
Git pre-commit hook is set by each developer locally. It is hard to force all developer set same pre-commit
hooks, but there are some basic things should be check before commit, such as python style
, file should use \n as line end
, etc.
This PR is added to solve this problem, by using a python package pre-commit. Each developer should do two things to enable this feature.
- Install
pre-commit
package.pip install pre-commit
- Enable
pre-commit
package to manage Paddle git pre-commit in local directory, by runpre-commit install
in Paddle checkout directory.
Currently, some hooks are added, and all files are scan & fixed by this PR.
By the way, there is another thing I found about yapf
, the python formatter used by Paddle. Different version of yapf
could generate different result, with the same input python file. So, we must use the same yapf
when developing Paddle. pre-commit
also can help us to archive that.
pre-commit
is used only by Paddle developer, we should add some other tools (or just use pre-commit
package, I'm not sure) to complete the CI tests about these checks.