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
--- 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",