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 '--------------------------------------------------------------------------
120120#  uses git 1.8.
121121#  We need the following command to exit with 0 hence the echo in case
122122#  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+ }
125133
126134if  [[ " $MODIFIED_FILES "   ==  " no_match"   ]];  then 
127135    echo  " No file outside sklearn/externals and doc/sphinxext/sphinx_gallery has been modified" 
128136else 
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 
132140fi 
133141echo  -e " No problem detected by flake8\n" 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments