pylint_pre_commit.hook 782 字节
Newer Older
G
gongweibao 已提交
1 2 3 4 5 6 7 8
#!/bin/bash

TOTAL_ERRORS=0


DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export PYTHONPATH=$DIR:$PYTHONPATH

9 10 11 12 13 14 15
readonly VERSION="2.12.0"
version=$(pylint --version | grep 'pylint')

if ! [[ $version == *"$VERSION"* ]]; then
    pip install pylint==2.12.0 1>nul
fi

G
gongweibao 已提交
16
# The trick to remove deleted files: https://stackoverflow.com/a/2413151
17
for file in $(git diff --name-status | awk '$1 != "D" {print $2}'); do
G
gongweibao 已提交
18 19 20 21 22
    pylint --disable=all --load-plugins=docstring_checker \
    --enable=doc-string-one-line,doc-string-end-with,doc-string-with-all-args,doc-string-triple-quotes,doc-string-missing,doc-string-indent-error,doc-string-with-returns,doc-string-with-raises $file;
    TOTAL_ERRORS=$(expr $TOTAL_ERRORS + $?);
done

23
exit $TOTAL_ERRORS
G
gongweibao 已提交
24
#For now, just warning:
25
#exit 0