From 5c1b5a5a689cfd5e4b3c00d1de024c13540d95e8 Mon Sep 17 00:00:00 2001 From: gorkicode Date: Tue, 26 Oct 2021 01:02:32 -0300 Subject: [PATCH 1/2] Add message error type --- linter.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/linter.py b/linter.py index eaac836..4c8ea4d 100644 --- a/linter.py +++ b/linter.py @@ -18,6 +18,32 @@ class Pyflakes(PythonLinter): 'selector': 'source.python' } + def split_match(self, match): + # mark properly the type error message + + error = super().split_match(match) + if not error['match']: + return None + + warning_msg_regex = r'''(?x) + \b(?: + used| + unused| + redefines| + shadowed| + (may\sbe) + )\b + ''' + + warning_msg_regex = re.compile(warning_msg_regex, 0) + + if warning_msg_regex.search(error['message']): + error['warning'] = 'warning' + else: + error['error'] = 'error' + + return error + def reposition_match(self, line, col, match, vv): if 'imported but unused' in match.message: # Consider: From 509814cbc10aea1395ef4f1d751665530d022749 Mon Sep 17 00:00:00 2001 From: gorkicode Date: Wed, 17 Nov 2021 00:09:12 -0300 Subject: [PATCH 2/2] review for #18 - Add support for warnings --- linter.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/linter.py b/linter.py index 4c8ea4d..0719809 100644 --- a/linter.py +++ b/linter.py @@ -17,15 +17,7 @@ class Pyflakes(PythonLinter): defaults = { 'selector': 'source.python' } - - def split_match(self, match): - # mark properly the type error message - - error = super().split_match(match) - if not error['match']: - return None - - warning_msg_regex = r'''(?x) + warning_msg_regex = r'''(?x) \b(?: used| unused| @@ -33,14 +25,20 @@ def split_match(self, match): shadowed| (may\sbe) )\b - ''' + ''' - warning_msg_regex = re.compile(warning_msg_regex, 0) + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.warning_msg_regex = re.compile(self.warning_msg_regex, 0) - if warning_msg_regex.search(error['message']): - error['warning'] = 'warning' + def split_match(self, match): + # mark properly the type error message + + error = super().split_match(match) + if self.warning_msg_regex.search(error['message']): + error['error_type'] = 'warning' else: - error['error'] = 'error' + error['error_type'] = 'error' return error