diff --git a/linter.py b/linter.py index 04e189a..72b45fa 100644 --- a/linter.py +++ b/linter.py @@ -94,12 +94,12 @@ def find_errors(self, output): message = match.group('message') or '' word = match.group('word') - match_groups = match.groupdict() - error_type = next( - error_type_ - for error_type_ in ('errors', 'warnings', 'infos') - if error_type_ in match_groups - ) + matched_groups = match.groupdict() + error_type = singularize(next( + group + for group in ('errors', 'warnings', 'infos') + if group in matched_groups + )) row, col = self.view.rowcol(offset + match.start()) text_to_mark = match.group() if self.settings.get('mark_message') else word @@ -111,3 +111,11 @@ def find_errors(self, output): code=word, message=message ) + + +def singularize(word): + return { + "errors": "error", + "warnings": "warning", + "infos": "info", + }[word]