summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/python/mypy.vim17
-rw-r--r--autoload/ale/fixers/autopep8.vim2
-rw-r--r--autoload/ale/fixers/isort.vim2
-rw-r--r--autoload/ale/fixers/yapf.vim2
-rw-r--r--autoload/ale/python.vim8
-rw-r--r--doc/ale-python.txt5
-rw-r--r--test/command_callback/test_mypy_command_callback.vader18
7 files changed, 23 insertions, 31 deletions
diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim
index 3c8b181f..e39ee349 100644
--- a/ale_linters/python/mypy.vim
+++ b/ale_linters/python/mypy.vim
@@ -7,19 +7,7 @@ let g:ale_python_mypy_options = get(g:, 'ale_python_mypy_options', '')
let g:ale_python_mypy_use_global = get(g:, 'ale_python_mypy_use_global', 0)
function! ale_linters#python#mypy#GetExecutable(buffer) abort
- if !ale#Var(a:buffer, 'python_mypy_use_global')
- let l:virtualenv = ale#python#FindVirtualenv(a:buffer)
-
- if !empty(l:virtualenv)
- let l:ve_mypy = l:virtualenv . '/bin/mypy'
-
- if executable(l:ve_mypy)
- return l:ve_mypy
- endif
- endif
- endif
-
- return ale#Var(a:buffer, 'python_mypy_executable')
+ return ale#python#FindExecutable(a:buffer, 'python_mypy', ['/bin/mypy'])
endfunction
function! ale_linters#python#mypy#GetCommand(buffer) abort
@@ -33,7 +21,7 @@ function! ale_linters#python#mypy#GetCommand(buffer) abort
\ . ale#Escape(l:executable)
\ . ' --show-column-numbers '
\ . ale#Var(a:buffer, 'python_mypy_options')
- \ . ' %s'
+ \ . ' --shadow-file %s %t %s'
endfunction
function! ale_linters#python#mypy#Handle(buffer, lines) abort
@@ -69,5 +57,4 @@ call ale#linter#Define('python', {
\ 'executable_callback': 'ale_linters#python#mypy#GetExecutable',
\ 'command_callback': 'ale_linters#python#mypy#GetCommand',
\ 'callback': 'ale_linters#python#mypy#Handle',
-\ 'lint_file': 1,
\})
diff --git a/autoload/ale/fixers/autopep8.vim b/autoload/ale/fixers/autopep8.vim
index 8bfc0d90..908980dc 100644
--- a/autoload/ale/fixers/autopep8.vim
+++ b/autoload/ale/fixers/autopep8.vim
@@ -12,7 +12,7 @@ function! ale#fixers#autopep8#Fix(buffer) abort
\ ['/bin/autopep8'],
\)
- if empty(l:executable)
+ if !executable(l:executable)
return 0
endif
diff --git a/autoload/ale/fixers/isort.vim b/autoload/ale/fixers/isort.vim
index e1ddcda3..067d44dd 100644
--- a/autoload/ale/fixers/isort.vim
+++ b/autoload/ale/fixers/isort.vim
@@ -11,7 +11,7 @@ function! ale#fixers#isort#Fix(buffer) abort
\ ['/bin/isort'],
\)
- if empty(l:executable)
+ if !executable(l:executable)
return 0
endif
diff --git a/autoload/ale/fixers/yapf.vim b/autoload/ale/fixers/yapf.vim
index fe6512aa..117a9550 100644
--- a/autoload/ale/fixers/yapf.vim
+++ b/autoload/ale/fixers/yapf.vim
@@ -11,7 +11,7 @@ function! ale#fixers#yapf#Fix(buffer) abort
\ ['/bin/yapf'],
\)
- if empty(l:executable)
+ if !executable(l:executable)
return 0
endif
diff --git a/autoload/ale/python.vim b/autoload/ale/python.vim
index a88b4b62..02e26b41 100644
--- a/autoload/ale/python.vim
+++ b/autoload/ale/python.vim
@@ -58,11 +58,5 @@ function! ale#python#FindExecutable(buffer, base_var_name, path_list) abort
endfor
endif
- let l:global_executable = ale#Var(a:buffer, a:base_var_name . '_executable')
-
- if executable(l:global_executable)
- return l:global_executable
- endif
-
- return ''
+ return ale#Var(a:buffer, a:base_var_name . '_executable')
endfunction
diff --git a/doc/ale-python.txt b/doc/ale-python.txt
index ddbe9e3a..38f96590 100644
--- a/doc/ale-python.txt
+++ b/doc/ale-python.txt
@@ -107,6 +107,11 @@ g:ale_python_isort_use_global *g:ale_python_isort_use_global*
-------------------------------------------------------------------------------
mypy *ale-python-mypy*
+The minimum supported version of mypy that ALE supports is v0.4.4. This is
+the first version containing the `--shadow-file` option ALE needs to be able
+to check for errors while you type.
+
+
g:ale_python_mypy_executable *g:ale_python_mypy_executable*
*b:ale_python_mypy_executable*
Type: |String|
diff --git a/test/command_callback/test_mypy_command_callback.vader b/test/command_callback/test_mypy_command_callback.vader
index 14c9af43..19141805 100644
--- a/test/command_callback/test_mypy_command_callback.vader
+++ b/test/command_callback/test_mypy_command_callback.vader
@@ -20,7 +20,8 @@ Execute(The mypy callbacks should return the correct default values):
\ 'mypy',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
- \ 'cd ''' . g:dir . ''' && ''mypy'' --show-column-numbers %s',
+ \ 'cd ''' . g:dir . ''' && ''mypy'' --show-column-numbers '
+ \ . '--shadow-file %s %t %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(The mypy executable should be configurable, and escaped properly):
@@ -30,14 +31,16 @@ Execute(The mypy executable should be configurable, and escaped properly):
\ 'executable with spaces',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
- \ 'cd ''' . g:dir . ''' && ''executable with spaces'' --show-column-numbers %s',
+ \ 'cd ''' . g:dir . ''' && ''executable with spaces'' --show-column-numbers '
+ \ . '--shadow-file %s %t %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(The mypy command callback should let you set options):
let g:ale_python_mypy_options = '--some-option'
AssertEqual
- \ 'cd ''' . g:dir . ''' && ''mypy'' --show-column-numbers --some-option %s',
+ \ 'cd ''' . g:dir . ''' && ''mypy'' --show-column-numbers --some-option '
+ \ . '--shadow-file %s %t %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(The mypy command should switch directories to the detected project root):
@@ -47,7 +50,8 @@ Execute(The mypy command should switch directories to the detected project root)
\ 'mypy',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
- \ 'cd ''' . g:dir . '/python_paths/no_virtualenv/subdir'' && ''mypy'' --show-column-numbers %s',
+ \ 'cd ''' . g:dir . '/python_paths/no_virtualenv/subdir'' && ''mypy'' --show-column-numbers '
+ \ . '--shadow-file %s %t %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(The mypy callbacks should detect virtualenv directories and switch to the project root):
@@ -58,7 +62,8 @@ Execute(The mypy callbacks should detect virtualenv directories and switch to th
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
\ 'cd ''' . g:dir . '/python_paths/with_virtualenv/subdir'' && '''
- \ . g:dir . '/python_paths/with_virtualenv/env/bin/mypy'' --show-column-numbers %s',
+ \ . g:dir . '/python_paths/with_virtualenv/env/bin/mypy'' --show-column-numbers '
+ \ . '--shadow-file %s %t %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(You should able able to use the global mypy instead):
@@ -69,5 +74,6 @@ Execute(You should able able to use the global mypy instead):
\ 'mypy',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
- \ 'cd ''' . g:dir . '/python_paths/with_virtualenv/subdir'' && ''mypy'' --show-column-numbers %s',
+ \ 'cd ''' . g:dir . '/python_paths/with_virtualenv/subdir'' && ''mypy'' --show-column-numbers '
+ \ . '--shadow-file %s %t %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))