mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-13 16:14:18 +00:00
skipping lines that end with #noqa
This commit is contained in:
parent
9e283b063f
commit
611db91aae
2 changed files with 15 additions and 3 deletions
|
|
@ -55,10 +55,20 @@ def check(codeString, filename):
|
||||||
# Okay, it's syntactically valid. Now check it.
|
# Okay, it's syntactically valid. Now check it.
|
||||||
w = checker.Checker(tree, filename)
|
w = checker.Checker(tree, filename)
|
||||||
w.messages.sort(lambda a, b: cmp(a.lineno, b.lineno))
|
w.messages.sort(lambda a, b: cmp(a.lineno, b.lineno))
|
||||||
for warning in w.messages:
|
valid_warnings = 0
|
||||||
print warning
|
|
||||||
return len(w.messages)
|
|
||||||
|
|
||||||
|
for warning in w.messages:
|
||||||
|
if _noqa(warning):
|
||||||
|
continue
|
||||||
|
print warning
|
||||||
|
valid_warnings += 1
|
||||||
|
|
||||||
|
return valid_warnings
|
||||||
|
|
||||||
|
def _noqa(warning):
|
||||||
|
# XXX quick dirty hack, just need to keep the line in the warning
|
||||||
|
line = open(warning.filename).readlines()[warning.lineno-1]
|
||||||
|
return line.strip().lower().endswith('# noqa')
|
||||||
|
|
||||||
def checkPath(filename):
|
def checkPath(filename):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -935,6 +935,8 @@ class Checker(object):
|
||||||
"""
|
"""
|
||||||
Report an error, according to options.
|
Report an error, according to options.
|
||||||
"""
|
"""
|
||||||
|
if self.physical_line.strip().lower().endswith('# noqa'):
|
||||||
|
return
|
||||||
if options.quiet == 1 and not self.file_errors:
|
if options.quiet == 1 and not self.file_errors:
|
||||||
message(self.filename)
|
message(self.filename)
|
||||||
self.file_errors += 1
|
self.file_errors += 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue