Skip to content

Commit 9617bc9

Browse files
committed
Use ruff in pre-commit hook (#1)
1 parent ea027f2 commit 9617bc9

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

tools/githook/pre-commit

+4-9
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,14 @@ if [ "$FILES" != "" ]; then
1414
# each file.
1515
E=0
1616
for F in ${FILES}; do
17-
P=$(git show ":$F" | python3 -c "import sys; compile(sys.stdin.read(), '/dev/null', 'exec')")
18-
if [ "$?" != "0" ]; then
19-
echo "Errors in $F"
20-
echo $P
17+
18+
if ! git show ":$F" | ruff check - --quiet --stdin-filename "$F"; then
2119
E=1
22-
continue
2320
fi
2421

25-
R=$(git show ":$F" | pycodestyle -)
26-
if [ "$?" != "0" ]; then
27-
echo "Errors in $F"
28-
echo "$R"
22+
if ! git show ":$F" | ruff format - --quiet --check; then
2923
E=1
24+
echo "Formatting errors in $F, run 'make format'"
3025
fi
3126
done
3227
if [ "$E" != "0" ]; then

0 commit comments

Comments
 (0)