Skip to content

Commit f41ec82

Browse files
adhadsemattdangerw
andauthored
Whitelisted formatting and lint check targets (#126)
* Fixed lint.sh and format.sh * Remove print Co-authored-by: Matt Watson <[email protected]>
1 parent 6537de9 commit f41ec82

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

shell/format.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/bin/bash -e
22

33
base_dir=$(dirname $(dirname $0))
4+
targets="${base_dir}/*.py ${base_dir}/examples/ ${base_dir}/keras_nlp/"
45

5-
isort --sl ${base_dir}
6-
black --line-length 80 ${base_dir}
6+
isort --sp "${base_dir}/setup.cfg" --sl ${targets}
7+
black --line-length 80 ${targets}
78

8-
for i in $(find ${base_dir} -name '*.py'); do
9+
for i in $(find ${targets} -name '*.py'); do
910
if ! grep -q Copyright $i; then
1011
echo $i
1112
cat shell/copyright.txt $i >$i.new && mv $i.new $i
1213
fi
1314
done
1415

15-
flake8 ${base_dir}
16+
flake8 --config "${base_dir}/setup.cfg" ${targets}

shell/lint.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
#!/bin/bash -e
22

33
base_dir=$(dirname $(dirname $0))
4+
targets="${base_dir}/*.py ${base_dir}/examples/ ${base_dir}/keras_nlp/"
45

5-
isort --sl -c "${base_dir}"
6+
isort --sp "${base_dir}/setup.cfg" --sl -c ${targets}
67
if ! [ $? -eq 0 ]; then
78
echo "Please run \"./shell/format.sh\" to format the code."
89
exit 1
910
fi
10-
flake8 "${base_dir}"
11+
12+
flake8 --config "${base_dir}/setup.cfg" ${targets}
1113
if ! [ $? -eq 0 ]; then
1214
echo "Please fix the code style issue."
1315
exit 1
1416
fi
15-
black --check --line-length 80 "${base_dir}"
17+
18+
black --check --line-length 80 ${targets}
1619
if ! [ $? -eq 0 ]; then
1720
echo "Please run \"./shell/format.sh\" to format the code."
1821
exit 1
1922
fi
20-
for i in $(find "${base_dir}" -name '*.py'); do
23+
for i in $(find ${targets} -name '*.py'); do
2124
if ! grep -q Copyright $i; then
2225
echo "Please run \"./shell/format.sh\" to format the code."
2326
exit 1

0 commit comments

Comments
 (0)