summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-02-04 19:47:37 +0000
committerw0rp <devw0rp@gmail.com>2017-02-04 19:47:37 +0000
commitd953c68ebbbb2cd28c2985394ccf16af903bb78d (patch)
tree24c33452490958001041ac8c03ae2d36ca87ef2e
parent829f87bc6a63cd442c7e2bf55870faa8804668a4 (diff)
downloadale-d953c68ebbbb2cd28c2985394ccf16af903bb78d.zip
Fix mypy error parsing when column numbers are included.
-rw-r--r--ale_linters/python/mypy.vim4
-rw-r--r--test/test_mypy_handler.vader10
2 files changed, 13 insertions, 1 deletions
diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim
index 934961b1..1509d9e6 100644
--- a/ale_linters/python/mypy.vim
+++ b/ale_linters/python/mypy.vim
@@ -16,6 +16,8 @@ function! g:ale_linters#python#mypy#GetCommand(buffer) abort
\ . g:ale_python_mypy_options
endfunction
+let s:path_pattern = '[a-zA-Z]\?\\\?:\?[[:alnum:]/\.\-_]\+'
+
function! g:ale_linters#python#mypy#Handle(buffer, lines) abort
" Look for lines like the following:
"
@@ -24,7 +26,7 @@ function! g:ale_linters#python#mypy#Handle(buffer, lines) abort
" Lines like these should be ignored below:
"
" file.py:4: note: (Stub files are from https://github.com/python/typeshed)
- let l:pattern = '^.\+:\(\d\+\):\?\(\d\+\)\?: \([^:]\+\): \(.\+\)$'
+ let l:pattern = '^' . s:path_pattern . ':\(\d\+\):\?\(\d\+\)\?: \([^:]\+\): \(.\+\)$'
let l:output = []
for l:line in a:lines
diff --git a/test/test_mypy_handler.vader b/test/test_mypy_handler.vader
index 5fe17f75..f886501f 100644
--- a/test/test_mypy_handler.vader
+++ b/test/test_mypy_handler.vader
@@ -12,10 +12,20 @@ Execute(The mypy handler should parse lines correctly):
\ 'type': 'E',
\ 'nr': -1,
\ },
+ \ {
+ \ 'bufnr': 347,
+ \ 'lnum': 40,
+ \ 'vcol': 0,
+ \ 'col': 5,
+ \ 'text': "Some other problem",
+ \ 'type': 'E',
+ \ 'nr': -1,
+ \ },
\ ],
\ ale_linters#python#mypy#Handle(347, [
\ "file.py:4: error: No library stub file for module 'django.db'",
\ 'file.py:4: note: (Stub files are from https://github.com/python/typeshed)',
+ \ "file.py:40:5: error: Some other problem",
\ ])
After: