1313
1414from contextlib import contextmanager
1515from functools import partial
16+ import SublimeLinter .lint
1617from SublimeLinter .lint import PythonLinter , persist , util
1718
18-
19- import SublimeLinter .lint
2019if getattr (SublimeLinter .lint , 'VERSION' , 3 ) > 3 :
2120 from SublimeLinter .lint import const
2221 WARNING = const .WARNING
22+ cmd = 'pydocstyle'
23+ module = None
2324else :
2425 from SublimeLinter .lint import highlight
2526 WARNING = highlight .WARNING
27+ cmd = 'pydocstyle@python'
28+ module = 'pydocstyle'
2629
2730
2831class Pydocstyle (PythonLinter ):
2932 """Provides an interface to the pydocstyle python module/script."""
3033
3134 syntax = 'python'
32- cmd = 'pydocstyle@python'
35+ cmd = cmd
3336 version_args = '--version'
3437 version_re = r'(?P<version>\d+\.\d+\.\d+)'
3538 version_requirement = '>= 0.3.0'
@@ -39,7 +42,7 @@ class Pydocstyle(PythonLinter):
3942 error_stream = util .STREAM_BOTH
4043 line_col_base = (1 , 0 ) # uses one-based line and zero-based column numbers
4144 tempfile_suffix = 'py'
42- module = 'pydocstyle'
45+ module = module
4346 defaults = {
4447 '--add-ignore=' : '' ,
4548 '--add-select=' : '' ,
@@ -59,30 +62,31 @@ class Pydocstyle(PythonLinter):
5962 'ignore-decorators'
6063 ]
6164
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 ))
6569
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 ))
6872
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 ()
7579
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 ))
8488
85- return errors
89+ return errors
8690
8791
8892@contextmanager
0 commit comments