diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-06-07 18:02:53 -0500 |
|---|---|---|
| committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-06-07 18:02:53 -0500 |
| commit | 8362fa7acdf90693fa745dc3ada33406170f43bd (patch) | |
| tree | 007f67c317503e26dfcabcab2283cc9b4e04295b /flake8/style_guide.py | |
| parent | 9ebaa5c69c7dc7077d1f59141a863d22e23284c0 (diff) | |
| download | flake8-8362fa7acdf90693fa745dc3ada33406170f43bd.tar.gz | |
Add distinction between reported and ignored errors
This allows us to properly exit if no errors were reported (due to,
for example, # noqa).
Diffstat (limited to 'flake8/style_guide.py')
| -rw-r--r-- | flake8/style_guide.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/flake8/style_guide.py b/flake8/style_guide.py index 6be9ff6..89890ba 100644 --- a/flake8/style_guide.py +++ b/flake8/style_guide.py @@ -233,8 +233,29 @@ class StyleGuide(object): def handle_error(self, code, filename, line_number, column_number, text, physical_line=None): - # type: (str, str, int, int, str) -> NoneType - """Handle an error reported by a check.""" + # type: (str, str, int, int, str) -> int + """Handle an error reported by a check. + + :param str code: + The error code found, e.g., E123. + :param str filename: + The file in which the error was found. + :param int line_number: + The line number (where counting starts at 1) at which the error + occurs. + :param int column_number: + The column number (where counting starts at 1) at which the error + occurs. + :param str text: + The text of the error message. + :param str physical_line: + The actual physical line causing the error. + :returns: + 1 if the error was reported. 0 if it was ignored. This is to allow + for counting of the number of errors found that were not ignored. + :rtype: + int + """ error = Error(code, filename, line_number, column_number, text, physical_line) if error.filename is None or error.filename == '-': @@ -247,6 +268,8 @@ class StyleGuide(object): is_included_in_diff): self.formatter.handle(error) self.listener.notify(error.code, error) + return 1 + return 0 def add_diff_ranges(self, diffinfo): """Update the StyleGuide to filter out information not in the diff. |
