@@ -6,7 +6,8 @@ set -e # o pipefail -v
66usage ()
77{
88 cat << USAGE >&2
9- usage: $( basename " $0 " ) [-h] [-l LINE_LENGTH] [files [files ...]]
9+ usage: $( basename " $0 " ) [-h] [-l LINE_LENGTH] [--skip-isort] [--skip-black]\
10+ [--skip-flake8] [files [files ...]]
1011
1112Python code style checker
1213
@@ -17,6 +18,9 @@ files files that need to be checked, all files\
1718optional arguments:
1819 -h, --help show this help message and exit
1920 -l, --line-length INT maximum length that any line may be
21+ --skip-isort skip isort Python imports checker
22+ --skip-black skip black Python code checker
23+ --skip-flake8 skip flake8 linter
2024USAGE
2125 exit 0
2226}
2630
2731FILES=" "
2832LINE_LENGTH=79
33+ SKIP_ISORT=" "
34+ SKIP_BLACK=" "
35+ SKIP_FLAKE8=" "
2936
3037while (( "$# " )) ; do
3138 case " $1 " in
@@ -36,6 +43,18 @@ while (( "$#" )); do
3643 LINE_LENGTH=$2
3744 shift 2
3845 ;;
46+ --skip-isort)
47+ SKIP_ISORT=" true"
48+ shift
49+ ;;
50+ --skip-black)
51+ SKIP_BLACK=" true"
52+ shift
53+ ;;
54+ --skip-flake8)
55+ SKIP_FLAKE8=" true"
56+ shift
57+ ;;
3958 -* |--* =) # unsupported flags
4059 echo " Error: Unsupported flag $1 " >&2
4160 exit 1
6079
6180
6281# ~ ~ ~ ~ ~ code checking ~ ~ ~ ~ ~
63- LINE_LENGTH=" ${LINE_LENGTH} " catalyst-codestyle-isort \
64- --diff \
65- --check-only \
66- -- ${FILES}
82+ if [[ -z " ${SKIP_ISORT} " ]]; then
83+ LINE_LENGTH=" ${LINE_LENGTH} " catalyst-codestyle-isort \
84+ --diff \
85+ --check-only \
86+ -- ${FILES}
87+ fi
6788
68- black --check --diff --line-length " ${LINE_LENGTH} " -- ${FILES}
89+ if [[ -z " ${SKIP_BLACK} " ]]; then
90+ black --check --diff --line-length " ${LINE_LENGTH} " -- ${FILES}
91+ fi
6992
70- LINE_LENGTH=" ${LINE_LENGTH} " catalyst-codestyle-flake8 \
71- --show-source \
72- --statistics \
73- --count \
74- -- ${FILES}
93+ if [[ -z " ${SKIP_FLAKE8} " ]]; then
94+ LINE_LENGTH=" ${LINE_LENGTH} " catalyst-codestyle-flake8 \
95+ --show-source \
96+ --statistics \
97+ --count \
98+ -- ${FILES}
99+ fi
0 commit comments