8000 The error report must explicitly call _ignore_code() before accept (#… · python-lsp/python-lsp-server@25f4b2a · GitHub
[go: up one dir, main page]

Skip to content

Commit 25f4b2a

Browse files
evandrocoangatesn
authored andcommitted
The error report must explicitly call _ignore_code() before accept (#234)
an error code and the `option` must to be None, so it cannot have that default value.
1 parent af4dcb3 commit 25f4b2a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pyls/plugins/pycodestyle_lint.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ def pyls_lint(config, document):
1919
'max_line_length': settings.get('maxLineLength'),
2020
'select': ','.join(settings.get('select') or []),
2121
}
22+
kwargs = {k: v for k, v in opts.items() if v}
23+
styleguide = pycodestyle.StyleGuide(kwargs)
2224

23-
styleguide = pycodestyle.StyleGuide({k: v for k, v in opts.items() if v is not None})
2425
c = pycodestyle.Checker(
2526
filename=document.uri, lines=document.lines, options=styleguide.options,
2627
report=PyCodeStyleDiagnosticReport(styleguide.options)
@@ -33,11 +34,19 @@ def pyls_lint(config, document):
3334

3435
class PyCodeStyleDiagnosticReport(pycodestyle.BaseReport):
3536

36-
def __init__(self, options=None):
37+
def __init__(self, options):
3738
self.diagnostics = []
3839
super(PyCodeStyleDiagnosticReport, self).__init__(options=options)
3940

4041
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+
4150
# PyCodeStyle will sometimes give you an error the line after the end of the file
4251
# e.g. no newline at end of file
4352
# In that case, the end offset should just be some number ~100
@@ -50,8 +59,6 @@ def error(self, line_number, offset, text, check):
5059
'character': 100 if line_number > len(self.lines) else len(self.lines[line_number - 1])
5160
},
5261
}
53-
code, _message = text.split(" ", 1)
54-
5562
self.diagnostics.append({
5663
'source': 'pycodestyle',
5764
'range': err_range,

0 commit comments

Comments
 (0)
0