forked from statsmodels/statsmodels
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint.sh
More file actions
executable file
·45 lines (38 loc) · 1.28 KB
/
lint.sh
File metadata and controls
executable file
·45 lines (38 loc) · 1.28 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
#!/bin/bash
echo "inside $0"
RET=0
echo "Running ruff check"
ruff check statsmodels
if [ "$LINT" == true ]; then
echo "Running flake8 linting"
echo "Linting all files with limited rules"
flake8 statsmodels
if [ $? -ne "0" ]; then
echo "Changed files failed linting using the required set of rules."
echo "Additions and changes must conform to Python code style rules."
RET=1
fi
# Tests any new python files
if [ -f $(git rev-parse --git-dir)/shallow ]; then
# Unshallow only when required, i.e., on CI
echo "Repository is shallow"
git fetch --unshallow --quiet
fi
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch origin --quiet
NEW_FILES=$(git diff origin/main --name-status -u -- "*.py" | grep ^A | cut -c 3- | paste -sd " " -)
if [ -n "$NEW_FILES" ]; then
echo "Linting newly added files with strict rules"
echo "New files: $NEW_FILES"
flake8 --isolated --max-line-length 88 --ignore=E203,E501,E701 $(eval echo $NEW_FILES)
if [ $? -ne "0" ]; then
echo "New files failed linting."
RET=1
fi
else
echo "No new files to lint"
fi
fi
echo "Running isort"
isort --check-only statsmodels
exit "$RET"