summaryrefslogtreecommitdiff
path: root/ale_linters/python
diff options
context:
space:
mode:
authorHarry Percival <hjwp2@cantab.net>2020-01-02 14:35:21 +0000
committerw0rp <w0rp@users.noreply.github.com>2020-01-02 14:35:21 +0000
commit72d2c55479c29e550c27f20e903c882dcc68639b (patch)
tree2fbadc16232275d842de74d42d0ca0305ab953c9 /ale_linters/python
parent57eba1afacc5c0889767d85c8304066ac91856b5 (diff)
downloadale-72d2c55479c29e550c27f20e903c882dcc68639b.zip
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
Diffstat (limited to 'ale_linters/python')
-rw-r--r--ale_linters/python/mypy.vim9
1 files changed, 9 insertions, 0 deletions
diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim
index d4778e40..94dfae7d 100644
--- a/ale_linters/python/mypy.vim
+++ b/ale_linters/python/mypy.vim
@@ -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)