Mypy: try to find folder containing mypy.ini to use as cwd. (#2385)

* When deciding which directory to run mypy from, prefer a folder with mypy.ini in it
* Add a test for mypy.ini-finding behaviour
This commit is contained in:
Harry Percival
2020-01-02 14:35:21 +00:00
committed by w0rp
parent 57eba1afac
commit 72d2c55479
5 changed files with 18 additions and 0 deletions

View File

@@ -19,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)