Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
Checker mypy: support for column numbers (@pbasista).
Browse files Browse the repository at this point in the history
  • Loading branch information
lcd047 committed Jan 4, 2018
1 parent 88dd656 commit 1b7ef51
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
22 changes: 16 additions & 6 deletions autoload/syntastic/preprocess.vim
Expand Up @@ -634,17 +634,27 @@ endfunction " }}}2
function! syntastic#preprocess#mypy(errors) abort " {{{2
let out = []
for e in a:errors
" new format
let parts = matchlist(e, '\v^(.{-1,}):(\d+): error: (.+)')
if len(parts) > 3
call add(out, join(parts[1:3], ':'))
" column numbers
let parts = matchlist(e, '\v^(.{-1,}):(\d+):(\d+): ([ew])%(rror|arning): (.+)')
if len(parts) > 5
let parts[3] += 1
call add(out, join(parts[1:5], ':'))
continue
endif

" old format
" no column numbers
let parts = matchlist(e, '\v^(.{-1,}):(\d+): ([ew])%(rror|arning): (.+)')
if len(parts) > 4
call add(out, join(parts[1:4], ':'))
continue
endif

" obsolete format
let parts = matchlist(e, '\v^(.{-1,}), line (\d+): (.+)')
if len(parts) > 3
call add(out, join(parts[1:3], ':'))
let parts[4] = parts[3]
let parts[3] = 'e'
call add(out, join(parts[1:4], ':'))
endif
endfor
return out
Expand Down
2 changes: 1 addition & 1 deletion plugin/syntastic.vim
Expand Up @@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START
endif

let g:_SYNTASTIC_VERSION = '3.8.0-100'
let g:_SYNTASTIC_VERSION = '3.8.0-101'
lockvar g:_SYNTASTIC_VERSION

" Sanity checks {{{1
Expand Down
13 changes: 10 additions & 3 deletions syntax_checkers/python/mypy.vim
Expand Up @@ -14,14 +14,21 @@ let s:save_cpo = &cpo
set cpo&vim

function! SyntaxCheckers_python_mypy_GetLocList() dict
let makeprg = self.makeprgBuild({})
if !exists('s:mypy_new')
" creative versioning: version string has changed from v0.4.6 to v0.470
" XXX the test should be fine for now, since 470 > 4
let s:mypy_new = syntastic#util#versionIsAtLeast(self.getVersion(), [0, 4, 5])
endif

let errorformat = '%f:%l:%m'
let makeprg = self.makeprgBuild({ 'args_after': (s:mypy_new ? '--show-column-numbers' : '') })

let errorformat =
\ '%f:%l:%c:%t:%m,' .
\ '%f:%l:%t:%m'

return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'defaults': { 'type': 'E' },
\ 'returns': [0, 1],
\ 'preprocess': 'mypy' })
endfunction
Expand Down

0 comments on commit 1b7ef51

Please sign in to comment.