Skip to content

Commit 75addb8

Browse files
author
Guillaume Lemaitre
committed
Update flake8-diff
1 parent fc3f69e commit 75addb8

File tree

1 file changed

+4
-24
lines changed

1 file changed

+4
-24
lines changed

build_tools/travis/flake8_diff.sh

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -113,29 +113,9 @@ echo -e '\nRunning flake8 on the diff in the range' "$COMMIT_RANGE" \
113113
"($(git rev-list $COMMIT_RANGE | wc -l) commit(s)):"
114114
echo '--------------------------------------------------------------------------------'
115115

116-
# We ignore files from sklearn/externals. Unfortunately there is no
117-
# way to do it with flake8 directly (the --exclude does not seem to
118-
# work with --diff). We could use the exclude magic in the git pathspec
119-
# ':!sklearn/externals' but it is only available on git 1.9 and Travis
120-
# uses git 1.8.
121-
# We need the following command to exit with 0 hence the echo in case
122-
# there is no match
123-
MODIFIED_FILES="$(git diff --name-only $COMMIT_RANGE | grep -v 'doc' \
124-
|| echo "no_match")"
125-
check_files() {
126-
files="$1"
127-
options="$2"
128-
# Conservative approach: diff without context (--unified=0) so that code
129-
# that was not changed does not create failures
130-
git diff --unified=0 $COMMIT_RANGE -- $files | flake8 --diff --show-source $options
131-
}
132-
133-
if [[ "$MODIFIED_FILES" == "no_match" ]]; then
134-
echo "No file outside doc has been modified"
135-
else
136-
check_files "$(echo "$MODIFIED_FILES" | grep -v ^examples)"
137-
# Examples are allowed to not have imports at top of file
138-
check_files "$(echo "$MODIFIED_FILES" | grep ^examples)" --ignore=E402
139-
fi
116+
# Check the imblearn folder
117+
git diff --unified=0 $COMMIT_RANGE -- 'imblearn' | flake8 --diff --show-source
118+
# Check the example folder
119+
git diff --unified=0 $COMMIT_RANGE -- 'examples' | flake8 --diff --show-source --ignore=E402
140120

141121
echo -e "No problem detected by flake8\n"

0 commit comments

Comments
 (0)