From bdcfebb0f3ba133325a776cf11151b7dfd98afe7 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Fri, 11 May 2018 15:05:16 +0200 Subject: [PATCH 1/3] Take emitted names as 'near' value and add it to the message --- linter.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/linter.py b/linter.py index cefffed..a58e0d9 100644 --- a/linter.py +++ b/linter.py @@ -3,7 +3,10 @@ class Pydocstyle(PythonLinter): cmd = 'pydocstyle' - regex = r'^.+?:(?P\d+).*:\r?\n\s*(?PD\d{3}):\s(?P.+)$' + regex = r'''(?x) + ^(?P.+):(?P\d+)[^`\n]*(`(?P.+)`)?.*:\n + \s*(?PD\d{3}):\s(?P.+) + ''' multiline = True default_type = const.WARNING error_stream = util.STREAM_BOTH @@ -19,3 +22,11 @@ class Pydocstyle(PythonLinter): '--convention=': '', '--ignore-decorators=': '' } + + def split_match(self, match): + match = super().split_match(match) + if match.near and '__init__' not in match.message: + return match._replace( + message='{} `{}`'.format(match.message, match.near)) + + return match From 68ccc4995e6d58f4cfed89d29c6c7f51d06e831c Mon Sep 17 00:00:00 2001 From: herr kaste Date: Fri, 11 May 2018 15:05:56 +0200 Subject: [PATCH 2/3] Handle parse errors silently --- linter.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/linter.py b/linter.py index a58e0d9..f757fbb 100644 --- a/linter.py +++ b/linter.py @@ -1,4 +1,5 @@ from SublimeLinter.lint import PythonLinter, util, const +from SublimeLinter.lint.linter import TransientError class Pydocstyle(PythonLinter): @@ -23,6 +24,15 @@ class Pydocstyle(PythonLinter): '--ignore-decorators=': '' } + def on_stderr(self, stderr): + # For a doc style tester, parse errors can be treated 'transient', + # for the benefit, that we do not re-draw, but keep the errors from + # the last run. + if 'Cannot parse file' in stderr: + raise TransientError('Parse error.') + + return super().on_stderr(stderr) + def split_match(self, match): match = super().split_match(match) if match.near and '__init__' not in match.message: From dd75e2f1d1d54debb2e210c3f7becd1eb52e2ce9 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Fri, 11 May 2018 15:11:48 +0200 Subject: [PATCH 3/3] Do not define what is the default anyway --- linter.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/linter.py b/linter.py index f757fbb..cab60e8 100644 --- a/linter.py +++ b/linter.py @@ -1,4 +1,4 @@ -from SublimeLinter.lint import PythonLinter, util, const +from SublimeLinter.lint import PythonLinter from SublimeLinter.lint.linter import TransientError @@ -9,8 +9,6 @@ class Pydocstyle(PythonLinter): \s*(?PD\d{3}):\s(?P.+) ''' multiline = True - default_type = const.WARNING - error_stream = util.STREAM_BOTH line_col_base = (1, 0) # uses one-based line and zero-based column numbers tempfile_suffix = 'py' defaults = {