1- from SublimeLinter .lint import PythonLinter , util , const
1+ from SublimeLinter .lint import PythonLinter
2+ from SublimeLinter .lint .linter import TransientError
23
34
45class Pydocstyle (PythonLinter ):
56 cmd = 'pydocstyle'
6- regex = r'^.+?:(?P<line>\d+).*:\r?\n\s*(?P<warning>D\d{3}):\s(?P<message>.+)$'
7+ regex = r'''(?x)
8+ ^(?P<filename>.+):(?P<line>\d+)[^`\n]*(`(?P<near>.+)`)?.*:\n
9+ \s*(?P<warning>D\d{3}):\s(?P<message>.+)
10+ '''
711 multiline = True
8- default_type = const .WARNING
9- error_stream = util .STREAM_BOTH
1012 line_col_base = (1 , 0 ) # uses one-based line and zero-based column numbers
1113 tempfile_suffix = 'py'
1214 defaults = {
@@ -19,3 +21,20 @@ class Pydocstyle(PythonLinter):
1921 '--convention=' : '' ,
2022 '--ignore-decorators=' : ''
2123 }
24+
25+ def on_stderr (self , stderr ):
26+ # For a doc style tester, parse errors can be treated 'transient',
27+ # for the benefit, that we do not re-draw, but keep the errors from
28+ # the last run.
29+ if 'Cannot parse file' in stderr :
30+ raise TransientError ('Parse error.' )
31+
32+ return super ().on_stderr (stderr )
33+
34+ def split_match (self , match ):
35+ match = super ().split_match (match )
36+ if match .near and '__init__' not in match .message :
37+ return match ._replace (
38+ message = '{} `{}`' .format (match .message , match .near ))
39+
40+ return match
0 commit comments