summaryrefslogtreecommitdiff
path: root/ale_linters/python/mypy.vim
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters/python/mypy.vim')
-rw-r--r--ale_linters/python/mypy.vim23
1 files changed, 21 insertions, 2 deletions
diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim
index dc4044e6..94dfae7d 100644
--- a/ale_linters/python/mypy.vim
+++ b/ale_linters/python/mypy.vim
@@ -3,6 +3,7 @@
call ale#Set('python_mypy_executable', 'mypy')
call ale#Set('python_mypy_ignore_invalid_syntax', 0)
+call ale#Set('python_mypy_show_notes', 1)
call ale#Set('python_mypy_options', '')
call ale#Set('python_mypy_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_mypy_auto_pipenv', 0)
@@ -18,6 +19,15 @@ endfunction
" The directory to change to before running mypy
function! s:GetDir(buffer) abort
+ " If we find a directory with "mypy.ini" in it use that,
+ " else try and find the "python project" root, or failing
+ " that, run from the same folder as the current file
+ for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
+ if filereadable(l:path . '/mypy.ini')
+ return l:path
+ endif
+ endfor
+
let l:project_root = ale#python#FindProjectRoot(a:buffer)
return !empty(l:project_root)
@@ -51,7 +61,16 @@ function! 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 = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: (error|warning): (.+)$'
+
+ let l:types = 'error|warning'
+
+ if ale#Var(a:buffer, 'python_mypy_show_notes')
+ let l:types = 'error|warning|note'
+ endif
+
+ let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: ('
+ \ . l:types
+ \ . '): (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
@@ -65,7 +84,7 @@ function! ale_linters#python#mypy#Handle(buffer, lines) abort
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
- \ 'type': l:match[4] is# 'error' ? 'E' : 'W',
+ \ 'type': l:match[4] is# 'error' ? 'E' : (l:match[4] is# 'note' ? 'I': 'W'),
\ 'text': l:match[5],
\})
endfor