@@ -19,8 +19,9 @@ def pyls_lint(config, document):
19
19
'max_line_length' : settings .get ('maxLineLength' ),
20
20
'select' : ',' .join (settings .get ('select' ) or []),
21
21
}
22
+ kwargs = {k : v for k , v in opts .items () if v }
23
+ styleguide = pycodestyle .StyleGuide (kwargs )
22
24
23
- styleguide = pycodestyle .StyleGuide ({k : v for k , v in opts .items () if v is not None })
24
25
c = pycodestyle .Checker (
25
26
filename = document .uri , lines = document .lines , options = styleguide .options ,
26
27
report = PyCodeStyleDiagnosticReport (styleguide .options )
@@ -33,11 +34,19 @@ def pyls_lint(config, document):
33
34
34
35
class PyCodeStyleDiagnosticReport (pycodestyle .BaseReport ):
35
36
36
- def __init__ (self , options = None ):
37
+ def __init__ (self , options ):
37
38
self .diagnostics = []
38
39
super (PyCodeStyleDiagnosticReport , self ).__init__ (options = options )
39
40
40
41
def error (self , line_number , offset , text , check ):
42
+ code = text [:4 ]
43
+ if self ._ignore_code (code ):
44
+ return
45
+
46
+ # Don't care about expected errors or warnings
47
+ if code in self .expected :
48
+ return
49
+
41
50
# PyCodeStyle will sometimes give you an error the line after the end of the file
42
51
# e.g. no newline at end of file
43
52
# In that case, the end offset should just be some number ~100
@@ -50,8 +59,6 @@ def error(self, line_number, offset, text, check):
50
59
'character' : 100 if line_number > len (self .lines ) else len (self .lines [line_number - 1 ])
51
60
},
52
61
}
53
- code , _message = text .split (" " , 1 )
54
-
55
62
self .diagnostics .append ({
56
63
'source' : 'pycodestyle' ,
57
64
'range' : err_range ,
0 commit comments