diff --git a/flake8/__init__.py b/flake8/__init__.py index baf501f..b94269f 100644 --- a/flake8/__init__.py +++ b/flake8/__init__.py @@ -55,10 +55,20 @@ def check(codeString, filename): # Okay, it's syntactically valid. Now check it. w = checker.Checker(tree, filename) w.messages.sort(lambda a, b: cmp(a.lineno, b.lineno)) - for warning in w.messages: - print warning - return len(w.messages) + valid_warnings = 0 + 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): """ diff --git a/flake8/pep8.py b/flake8/pep8.py index 1f572f5..5d7b39d 100644 --- a/flake8/pep8.py +++ b/flake8/pep8.py @@ -935,6 +935,8 @@ class Checker(object): """ Report an error, according to options. """ + if self.physical_line.strip().lower().endswith('# noqa'): + return if options.quiet == 1 and not self.file_errors: message(self.filename) self.file_errors += 1