Bug 1289805 - Don't pass in --exclude to flake8 paths that contain custom configuration, r?smacleod draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 09 Aug 2016 16:28:13 -0400
changeset 401281 2fee365b3914effa0765facf196b0c8f74f24c04
parent 400444 6e191a55c3d23e83e6a2e72e4e80c1dc21516493
child 401282 73facf8f23450ffa8a674849cda880542ae9d969
push id26420
push userahalberstadt@mozilla.com
push dateTue, 16 Aug 2016 20:20:10 +0000
reviewerssmacleod
bugs1289805
milestone51.0a1
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",