Skip to content

Commit ec786c8

Browse files
committed
Add local lint script matching CI validate + mypy checks
1 parent c5bcffd commit ec786c8

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

lint.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
# Local lint script matching the CI Validate job + mypy type checks.
3+
# Fixes formatting and import sorting in-place, then re-verifies in
4+
# check mode to catch any conflicts between the two, and runs mypy.
5+
set -euo pipefail
6+
7+
err=0
8+
9+
echo "==> ruff format (auto-fixing)"
10+
python -m ruff format spacy
11+
12+
echo "==> ruff isort (auto-fixing)"
13+
python -m ruff check spacy --select I --fix
14+
15+
echo "==> ruff format (verify)"
16+
if ! python -m ruff format spacy --check; then
17+
echo "FAIL: isort fix broke formatting"
18+
err=1
19+
fi
20+
21+
echo "==> ruff isort (verify)"
22+
if ! python -m ruff check spacy --select I; then
23+
echo "FAIL: format fix broke import sorting"
24+
err=1
25+
fi
26+
27+
echo "==> mypy"
28+
if ! python -m mypy spacy; then
29+
err=1
30+
fi
31+
32+
if [ "$err" -ne 0 ]; then
33+
echo "FAIL: see errors above"
34+
exit 1
35+
fi
36+
37+
echo "OK: all checks passed"

0 commit comments

Comments
 (0)