13
13
14
14
from contextlib import contextmanager
15
15
from functools import partial
16
+ import SublimeLinter .lint
16
17
from SublimeLinter .lint import PythonLinter , persist , util
17
18
18
-
19
- import SublimeLinter .lint
20
19
if getattr (SublimeLinter .lint , 'VERSION' , 3 ) > 3 :
21
20
from SublimeLinter .lint import const
22
21
WARNING = const .WARNING
22
+ cmd = 'pydocstyle'
23
+ module = None
23
24
else :
24
25
from SublimeLinter .lint import highlight
25
26
WARNING = highlight .WARNING
27
+ cmd = 'pydocstyle@python'
28
+ module = 'pydocstyle'
26
29
27
30
28
31
class Pydocstyle (PythonLinter ):
29
32
"""Provides an interface to the pydocstyle python module/script."""
30
33
31
34
syntax = 'python'
32
- cmd = 'pydocstyle@python'
35
+ cmd = cmd
33
36
version_args = '--version'
34
37
version_re = r'(?P<version>\d+\.\d+\.\d+)'
35
38
version_requirement = '>= 0.3.0'
@@ -39,7 +42,7 @@ class Pydocstyle(PythonLinter):
39
42
error_stream = util .STREAM_BOTH
40
43
line_col_base = (1 , 0 ) # uses one-based line and zero-based column numbers
41
44
tempfile_suffix = 'py'
42
- module = 'pydocstyle'
45
+ module = module
43
46
defaults = {
44
47
'--add-ignore=' : '' ,
45
48
'--add-select=' : '' ,
@@ -59,30 +62,31 @@ class Pydocstyle(PythonLinter):
59
62
'ignore-decorators'
60
63
]
61
64
62
- def check (self , code , filename ):
63
- """Run pydocstyle on code and return the output."""
64
- args = self .build_args (self .get_view_settings (inline = True ))
65
+ if getattr (SublimeLinter .lint , 'VERSION' , 3 ) < 4 :
66
+ def check (self , code , filename ):
67
+ """Run pydocstyle on code and return the output."""
68
+ args = self .build_args (self .get_view_settings (inline = True ))
65
69
66
- if persist .settings .get ('debug' ):
67
- persist .printf ('{} args: {}' .format (self .name , args ))
70
+ if persist .settings .get ('debug' ):
71
+ persist .printf ('{} args: {}' .format (self .name , args ))
68
72
69
- conf = self .module .config .ConfigurationParser ()
70
- with partialpatched (conf ,
71
- '_parse_args' ,
72
- args = args + [filename ],
73
- values = None ):
74
- conf .parse ()
73
+ conf = self .module .config .ConfigurationParser ()
74
+ with partialpatched (conf ,
75
+ '_parse_args' ,
76
+ args = args + [filename ],
77
+ values = None ):
78
+ conf .parse ()
75
79
76
- errors = []
77
- for fname , checked_codes , ignore_decorators in \
78
- conf .get_files_to_check ():
79
- errors .extend (
80
- self .module .check (
81
- [fname ],
82
- select = checked_codes ,
83
- ignore_decorators = ignore_decorators ))
80
+ errors = []
81
+ for fname , checked_codes , ignore_decorators in \
82
+ conf .get_files_to_check ():
83
+ errors .extend (
84
+ self .module .check (
85
+ [fname ],
86
+ select = checked_codes ,
87
+ ignore_decorators = ignore_decorators ))
84
88
85
- return errors
89
+ return errors
86
90
87
91
88
92
@contextmanager
0 commit comments