From 6e5cf10158819b56272519815879675c31984c36 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Sun, 17 Jul 2022 14:06:35 +0200 Subject: [PATCH] Hotfix: error types are reserved words Fixes #42 The error types herein are actually singular versions of our setting keys. Especially clear in the wrong variable name `error_type_` as we actually do *not* iterate over error types but captured word groups. --- linter.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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]