diff --git a/linter.py b/linter.py index cefffed..cab60e8 100644 --- a/linter.py +++ b/linter.py @@ -1,12 +1,14 @@ -from SublimeLinter.lint import PythonLinter, util, const +from SublimeLinter.lint import PythonLinter +from SublimeLinter.lint.linter import TransientError 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 line_col_base = (1, 0) # uses one-based line and zero-based column numbers tempfile_suffix = 'py' defaults = { @@ -19,3 +21,20 @@ class Pydocstyle(PythonLinter): '--convention=': '', '--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: + return match._replace( + message='{} `{}`'.format(match.message, match.near)) + + return match