-
Notifications
You must be signed in to change notification settings - Fork 153
Expand file tree
/
Copy pathlint.sh
More file actions
executable file
·65 lines (54 loc) · 1.15 KB
/
Copy pathlint.sh
File metadata and controls
executable file
·65 lines (54 loc) · 1.15 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
if [ "$1" = "" ]; then
ACTION="fix"
else
ACTION="$1"
fi
if [ "$ACTION" = "install" ]; then
set -ex
pip install ruff==0.15.14 pyrefly==1.0.0
exit 0
fi
if ! (which ruff >/dev/null && which pyrefly >/dev/null); then
echo "ruff/pyrefly not installed. Run ./lint.sh install"
exit 1
fi
VALID_ACTION="false"
ERRORS=""
function run {
echo "+" $@ 1>&2
$@
if [ $? -ne 0 ]; then
ERRORS="$ERRORS"$'\n'"ERROR running: $@"
fi
VALID_ACTION="true"
}
PYREFLY="scripts/pyrefly_check.sh"
if [ "$ACTION" = "fix" ]; then
run ruff format
run ruff check --fix
run pre-commit run codespell --all-files
run $PYREFLY
fi
if [ "$ACTION" = "unsafe" ]; then
run ruff format
run ruff check --fix --unsafe-fixes
run pre-commit run codespell --all-files
run $PYREFLY
fi
if [ "$ACTION" = "check" ]; then
run ruff format --check --diff
run ruff check --no-fix
run pre-commit run codespell --all-files
run $PYREFLY
fi
if [ "$ERRORS" != "" ]; then
echo "$ERRORS" 1>&2
exit 1
fi
if [ "$VALID_ACTION" = "false" ]; then
echo "Invalid argument: $ACTION" 1>&2
echo "Usage: ./lint.sh [fix|check|install|unsafe]" 1>&2
exit 1
fi
exit 0