Fix bug with '# noqa' filtering (#3993)
This commit is contained in:
parent
33c9a91d85
commit
11dae722c2
2 changed files with 9 additions and 10 deletions
|
@ -139,14 +139,6 @@ def filter_file(source, dest, output=False):
|
||||||
# We still want to catch trailing whitespace warnings
|
# We still want to catch trailing whitespace warnings
|
||||||
line = line.rstrip('\n')
|
line = line.rstrip('\n')
|
||||||
|
|
||||||
if line == '# flake8: noqa':
|
|
||||||
# Entire file is ignored
|
|
||||||
break
|
|
||||||
|
|
||||||
if line.endswith('# noqa'):
|
|
||||||
# Line is already ignored
|
|
||||||
continue
|
|
||||||
|
|
||||||
for file_pattern, errors in exemptions.items():
|
for file_pattern, errors in exemptions.items():
|
||||||
if not file_pattern.search(source):
|
if not file_pattern.search(source):
|
||||||
continue
|
continue
|
||||||
|
@ -154,7 +146,10 @@ def filter_file(source, dest, output=False):
|
||||||
for code, patterns in errors.items():
|
for code, patterns in errors.items():
|
||||||
for pattern in patterns:
|
for pattern in patterns:
|
||||||
if pattern.search(line):
|
if pattern.search(line):
|
||||||
if '# noqa: ' in line:
|
if line.endswith('# noqa'):
|
||||||
|
# Line is already ignored
|
||||||
|
pass
|
||||||
|
elif '# noqa: ' in line:
|
||||||
line += ',{0}'.format(code)
|
line += ',{0}'.format(code)
|
||||||
else:
|
else:
|
||||||
line += ' # noqa: {0}'.format(code)
|
line += ' # noqa: {0}'.format(code)
|
||||||
|
|
|
@ -71,6 +71,10 @@ class Flake8(Package):
|
||||||
patch('hyper-specific-patch-that-fixes-some-random-bug-that-probably-only-affects-one-user.patch', when='%gcc@3.2.2:3.2.3')
|
patch('hyper-specific-patch-that-fixes-some-random-bug-that-probably-only-affects-one-user.patch', when='%gcc@3.2.2:3.2.3')
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
|
# Make sure lines with '# noqa' work as expected. Don't just
|
||||||
|
# remove them entirely. This will mess up the indentation of
|
||||||
|
# the following lines.
|
||||||
|
if 'really-long-if-statement' != 'that-goes-over-the-line-length-limit-and-requires-noqa': # noqa
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# '@when' decorated functions are exempt from redefinition errors
|
# '@when' decorated functions are exempt from redefinition errors
|
||||||
|
|
Loading…
Reference in a new issue