#852 Capture error codes for pycodestyle, and consider every code except E999 to be style errors or warnings
This commit is contained in:
parent
cf538c3a58
commit
1d65e5692f
@ -17,18 +17,27 @@ function! ale_linters#python#pycodestyle#GetCommand(buffer) abort
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#pycodestyle#Handle(buffer, lines) abort
|
||||
let l:pattern = '\v^(\S*):(\d*):(\d*): ((([EW])\d+) .*)$'
|
||||
let l:pattern = '\v^(\S*):(\d*):(\d*): ([EW]\d+) (.*)$'
|
||||
let l:output = []
|
||||
|
||||
" lines are formatted as follows:
|
||||
" file.py:21:26: W291 trailing whitespace
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
let l:item = {
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'type': l:match[6],
|
||||
\ 'text': l:match[4],
|
||||
\})
|
||||
\ 'type': l:match[4][0],
|
||||
\ 'sub_type': 'style',
|
||||
\ 'text': l:match[5],
|
||||
\ 'code': l:match[4],
|
||||
\}
|
||||
|
||||
" E999 is not a style error, it's a syntax error.
|
||||
if l:match[4] is# 'E999'
|
||||
unlet l:item.sub_type
|
||||
endif
|
||||
|
||||
call add(l:output, l:item)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
|
@ -9,37 +9,55 @@ Execute(The pycodestyle handler should parse output):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 8,
|
||||
\ 'col': 3,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'SyntaxError: invalid syntax',
|
||||
\ 'code': 'E999',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 69,
|
||||
\ 'col': 11,
|
||||
\ 'text': 'E401 multiple imports on one line',
|
||||
\ 'text': 'multiple imports on one line',
|
||||
\ 'code': 'E401',
|
||||
\ 'type': 'E',
|
||||
\ 'sub_type': 'style',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 77,
|
||||
\ 'col': 1,
|
||||
\ 'text': 'E302 expected 2 blank lines, found 1',
|
||||
\ 'text': 'expected 2 blank lines, found 1',
|
||||
\ 'code': 'E302',
|
||||
\ 'type': 'E',
|
||||
\ 'sub_type': 'style',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 88,
|
||||
\ 'col': 5,
|
||||
\ 'text': 'E301 expected 1 blank line, found 0',
|
||||
\ 'text': 'expected 1 blank line, found 0',
|
||||
\ 'code': 'E301',
|
||||
\ 'type': 'E',
|
||||
\ 'sub_type': 'style',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 222,
|
||||
\ 'col': 34,
|
||||
\ 'text': 'W602 deprecated form of raising exception',
|
||||
\ 'text': 'deprecated form of raising exception',
|
||||
\ 'code': 'W602',
|
||||
\ 'type': 'W',
|
||||
\ 'sub_type': 'style',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 544,
|
||||
\ 'col': 21,
|
||||
\ 'text': 'W601 .has_key() is deprecated, use ''in''',
|
||||
\ 'text': '.has_key() is deprecated, use ''in''',
|
||||
\ 'code': 'W601',
|
||||
\ 'type': 'W',
|
||||
\ 'sub_type': 'style',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#python#pycodestyle#Handle(bufnr(''), [
|
||||
\ 'stdin:8:3: E999 SyntaxError: invalid syntax',
|
||||
\ 'stdin:69:11: E401 multiple imports on one line',
|
||||
\ 'stdin:77:1: E302 expected 2 blank lines, found 1',
|
||||
\ 'stdin:88:5: E301 expected 1 blank line, found 0',
|
||||
|
Loading…
Reference in New Issue
Block a user