mirror of https://github.com/dense-analysis/ale
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:
parent
57eba1afac
commit
72d2c55479
|
@ -19,6 +19,15 @@ endfunction
|
||||||
|
|
||||||
" The directory to change to before running mypy
|
" The directory to change to before running mypy
|
||||||
function! s:GetDir(buffer) abort
|
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)
|
let l:project_root = ale#python#FindProjectRoot(a:buffer)
|
||||||
|
|
||||||
return !empty(l:project_root)
|
return !empty(l:project_root)
|
||||||
|
|
|
@ -52,6 +52,15 @@ Execute(The mypy callbacks should detect virtualenv directories and switch to th
|
||||||
\ . ' --show-column-numbers '
|
\ . ' --show-column-numbers '
|
||||||
\ . '--shadow-file %s %t %s'
|
\ . '--shadow-file %s %t %s'
|
||||||
|
|
||||||
|
Execute(The mypy callbacks should cd to directory containing mypy.ini if found):
|
||||||
|
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_mypy_ini_and_pytest_ini/tests/testsubfolder/my_tests.py')
|
||||||
|
|
||||||
|
AssertLinter 'mypy',
|
||||||
|
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_mypy_ini_and_pytest_ini'))
|
||||||
|
\ . ale#Escape('mypy')
|
||||||
|
\ . ' --show-column-numbers '
|
||||||
|
\ . '--shadow-file %s %t %s'
|
||||||
|
|
||||||
Execute(You should able able to use the global mypy instead):
|
Execute(You should able able to use the global mypy instead):
|
||||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
|
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
|
||||||
let g:ale_python_mypy_use_global = 1
|
let g:ale_python_mypy_use_global = 1
|
||||||
|
|
Loading…
Reference in New Issue