1
- from SublimeLinter .lint import PythonLinter , util , const
1
+ from SublimeLinter .lint import PythonLinter
2
+ from SublimeLinter .lint .linter import TransientError
2
3
3
4
4
5
class Pydocstyle (PythonLinter ):
5
6
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
+ '''
7
11
multiline = True
8
- default_type = const .WARNING
9
- error_stream = util .STREAM_BOTH
10
12
line_col_base = (1 , 0 ) # uses one-based line and zero-based column numbers
11
13
tempfile_suffix = 'py'
12
14
defaults = {
@@ -19,3 +21,20 @@ class Pydocstyle(PythonLinter):
19
21
'--convention=' : '' ,
20
22
'--ignore-decorators=' : ''
21
23
}
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