File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -120,14 +120,22 @@ echo '--------------------------------------------------------------------------
120
120
# uses git 1.8.
121
121
# We need the following command to exit with 0 hence the echo in case
122
122
# there is no match
123
- MODIFIED_FILES=$( git diff --name-only $COMMIT_RANGE | grep -v ' sklearn/externals' | \
124
- grep -v ' doc/sphinxext/sphinx_gallery' || echo " no_match" )
123
+ MODIFIED_FILES=" $( git diff --name-only $COMMIT_RANGE | grep -v ' sklearn/externals' | \
124
+ grep -v ' doc/sphinxext/sphinx_gallery' || echo " no_match" ) "
125
+
126
+ check_files () {
127
+ files=" $1 "
128
+ options=" $2 "
129
+ # Conservative approach: diff without context (--unified=0) so that code
130
+ # that was not changed does not create failures
131
+ git diff --unified=0 $COMMIT -- $files | flake8 --diff --show-source $options
132
+ }
125
133
126
134
if [[ " $MODIFIED_FILES " == " no_match" ]]; then
127
135
echo " No file outside sklearn/externals and doc/sphinxext/sphinx_gallery has been modified"
128
136
else
129
- # Conservative approach: diff without context so that code that
130
- # was not changed does not create failures
131
- git diff --unified=0 $COMMIT -- $MODIFIED_FILES | flake8 --diff --show-source
137
+ check_files " $( echo " $MODIFIED_FILES " | grep -v ^examples ) "
138
+ # Examples are allowed to not have imports at top of file
139
+ check_files " $( echo " $MODIFIED_FILES " | grep ^examples ) " --ignore=E402
132
140
fi
133
141
echo -e " No problem detected by flake8\n"
You can’t perform that action at this time.
0 commit comments