diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 39d9ae5e0dcd7aba9d77a71db207936f9518297d..06b9dfeb725dacddd2adf0dc025098d03270f9c1 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/Lucas-C/pre-commit-hooks.git - sha: v1.0.1 + rev: v1.1.14 hooks: - id: remove-crlf files: (?!.*third_party)^.*$ | (?!.*book)^.*$ diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index eac2f95d14b45fe46a285be02b03e748fe86e3ff..6ac1f6eb6b511fdf270b7986944a980c69ec1635 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -360,6 +360,10 @@ function check_style() { # pre-commit use python3.8.0 OLD_PATH=$PATH export PATH=/usr/local/python3.8.0/bin:/usr/local/python3.8.0/include:/usr/local/bin:${PATH} + + if ! [[ $(pre-commit --version) == *"2.17.0"* ]]; then + pip install pre-commit==2.17.0 + fi pre-commit install clang-format --version diff --git a/tools/codestyle/pylint_pre_commit.hook b/tools/codestyle/pylint_pre_commit.hook index 150a3f5666bd39d30b7e6518e58a14fb5fe2f14b..f0d2f0a22d79ead1fc12c7425e1c55f7e2c3fc40 100755 --- a/tools/codestyle/pylint_pre_commit.hook +++ b/tools/codestyle/pylint_pre_commit.hook @@ -6,6 +6,13 @@ TOTAL_ERRORS=0 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" export PYTHONPATH=$DIR:$PYTHONPATH +readonly VERSION="2.12.0" +version=$(pylint --version | grep 'pylint') + +if ! [[ $version == *"$VERSION"* ]]; then + pip install pylint==2.12.0 1>nul +fi + # The trick to remove deleted files: https://stackoverflow.com/a/2413151 for file in $(git diff --name-status | awk '$1 != "D" {print $2}'); do pylint --disable=all --load-plugins=docstring_checker \ @@ -16,4 +23,3 @@ done exit $TOTAL_ERRORS #For now, just warning: #exit 0 -