Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【code format check upgrade】 step1: pre-commit, remove-ctrlf, pylint #43103

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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)^.*$
Expand Down
4 changes: 4 additions & 0 deletions paddle/scripts/paddle_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以之后把pre-commit, remove-ctrlf, pylint都打入镜像,避免CI 每次重新安装

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以之后把pre-commit, remove-ctrlf, pylint都打入镜像,避免CI 每次重新安装

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


pre-commit install
clang-format --version
Expand Down
8 changes: 7 additions & 1 deletion tools/codestyle/pylint_pre_commit.hook
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -16,4 +23,3 @@ done
exit $TOTAL_ERRORS
#For now, just warning:
#exit 0