Bug 1289805 - Don't pass in --exclude to flake8 paths that contain custom configuration, r=smacleod
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 09 Aug 2016 16:28:13 -0400
changeset 310079 98876f70367e0ab16ab8cd239d019efbf80f15be
parent 310078 97650364974418715bae51a0d1d9281b40f0b592
child 310080 fff9177fcfe49290b43631b06e78b1bf985ca3e3
push id80771
push userkwierso@gmail.com
push dateThu, 18 Aug 2016 23:33:08 +0000
treeherdermozilla-inbound@cb1295738c37 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmacleod
bugs1289805
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1289805 - Don't pass in --exclude to flake8 paths that contain custom configuration, r=smacleod This fixes a bug in flake8, where if you pass in --exclude to a path with a custom .flake8 file, that configuration will be ignored. I'm not sure why this happens. Prior to this commit series, the 'exclude' paths weren't being passed on to the flake8 linter properly. This is why the problems hasn't surfaced until now. This is a band-aid fix until a proper (likely upstream) fix can be landed. MozReview-Commit-ID: KYhC6SEySC3
tools/lint/flake8.lint
--- a/tools/lint/flake8.lint
+++ b/tools/lint/flake8.lint
@@ -92,31 +92,35 @@ def lint(files, **lintargs):
         return []
 
     cmdargs = [
         binary,
         '--format', '{"path":"%(path)s","lineno":%(row)s,'
                     '"column":%(col)s,"rule":"%(code)s","message":"%(text)s"}',
     ]
 
-    exclude = lintargs.get('exclude')
-    if exclude:
-        cmdargs += ['--exclude', ','.join(lintargs['exclude'])]
-
     # Run any paths with a .flake8 file in the directory separately so
     # it gets picked up. This means only .flake8 files that live in
     # directories that are explicitly included will be considered.
     # See bug 1277851
     no_config = []
     for f in files:
         if not os.path.isfile(os.path.join(f, '.flake8')):
             no_config.append(f)
             continue
         run_process(cmdargs+[f])
 
+    # XXX For some reason passing in --exclude results in flake8 not using
+    # the local .flake8 file. So for now only pass in --exclude if there
+    # is no local config.
+    exclude = lintargs.get('exclude')
+    if exclude:
+        cmdargs += ['--exclude', ','.join(lintargs['exclude'])]
+
+
     if no_config:
         run_process(cmdargs+no_config)
 
     return results
 
 
 LINTER = {
     'name': "flake8",