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.vim16
1 files changed, 5 insertions, 11 deletions
diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim
index 1e35d929..48697421 100644
--- a/ale_linters/python/mypy.vim
+++ b/ale_linters/python/mypy.vim
@@ -18,7 +18,7 @@ function! ale_linters#python#mypy#GetExecutable(buffer) abort
endfunction
" The directory to change to before running mypy
-function! s:GetDir(buffer) abort
+function! ale_linters#python#mypy#GetCwd(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
@@ -36,26 +36,19 @@ function! s:GetDir(buffer) abort
endfunction
function! ale_linters#python#mypy#GetCommand(buffer) abort
- let l:dir = s:GetDir(a:buffer)
let l:executable = ale_linters#python#mypy#GetExecutable(a:buffer)
-
let l:exec_args = l:executable =~? 'pipenv$'
\ ? ' run mypy'
\ : ''
- let l:options = ale#Var(a:buffer, 'python_mypy_options')
-
- " We have to always switch to an explicit directory for a command so
- " we can know with certainty the base path for the 'filename' keys below.
- return ale#path#CdString(l:dir)
- \ . ale#Escape(l:executable) . l:exec_args
- \ . (len(l:options) ? (' ' . l:options) : '')
+ return '%e' . l:exec_args
+ \ . ale#Pad(ale#Var(a:buffer, 'python_mypy_options'))
\ . ' --show-column-numbers'
\ . ' --shadow-file %s %t %s'
endfunction
function! ale_linters#python#mypy#Handle(buffer, lines) abort
- let l:dir = s:GetDir(a:buffer)
+ let l:dir = ale_linters#python#mypy#GetCwd(a:buffer)
" Look for lines like the following:
"
" file.py:4: error: No library stub file for module 'django.db'
@@ -97,6 +90,7 @@ endfunction
call ale#linter#Define('python', {
\ 'name': 'mypy',
\ 'executable': function('ale_linters#python#mypy#GetExecutable'),
+\ 'cwd': function('ale_linters#python#mypy#GetCwd'),
\ 'command': function('ale_linters#python#mypy#GetCommand'),
\ 'callback': 'ale_linters#python#mypy#Handle',
\ 'output_stream': 'both'