-
Notifications
You must be signed in to change notification settings - Fork 238
Expand file tree
/
Copy pathdocstrings_lint.sh
More file actions
executable file
·44 lines (42 loc) · 1.3 KB
/
docstrings_lint.sh
File metadata and controls
executable file
·44 lines (42 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# required in order to get the status of all the files at once
pip install darglint==1.6.0
pip install pydocstyle==5.1.1
echo ====================================================================================
echo DOCSTRINGS LINT: checking $CHANGED_FILES
echo ------------------------------------------------------------------------------------
echo 'removing files under /tests...'
arrVar=()
# we ignore tests files
for changed_file in $CHANGED_FILES; do
case ${changed_file} in
tests/* | \
.github/* | \
scripts/* | \
docarray/resources/* | \
docs/* | \
setup.py | \
fastentrypoints.py)
;;*)
echo keeping ${changed_file}
arrVar+=(${changed_file})
;;
esac
done
# if array is empty
if [ ${#arrVar[@]} -eq 0 ]; then
echo 'nothing to check'
exit 0
fi
DARGLINT_OUTPUT=$(darglint -v 2 -s sphinx "${arrVar[@]}"); PYDOCSTYLE_OUTPUT=$(pydocstyle --select=D101,D102,D103 "${arrVar[@]}")
# status captured here
if [[ -z "$PYDOCSTYLE_OUTPUT" ]] && [[ -z "$DARGLINT_OUTPUT" ]]; then
echo 'OK'
exit 0
else
echo 'failure. make sure to check the guide for docstrings: https://docarray.jina.ai/chapters/docstring.html'
echo $DARGLINT_OUTPUT
echo $PYDOCSTYLE_OUTPUT
exit 1
fi
echo ====================================================================================