Search python fixers in virtual environment (#632)

* Search python fixers in virtual environment

* Add tests for python fixers
This commit is contained in:
José Luis Lafuente
2017-06-07 20:42:30 +01:00
committed by w0rp
parent f61c6d4c0e
commit 1eec446620
8 changed files with 97 additions and 3 deletions
+6 -1
View File
@@ -2,7 +2,12 @@
" Description: Fixing files with autopep8.
function! ale#fixers#autopep8#Fix(buffer) abort
let l:executable = ale#handlers#python#GetExecutable(a:buffer, 'autopep8')
if empty(l:executable)
return 0
endif
return {
\ 'command': 'autopep8 -'
\ 'command': ale#Escape(l:executable) . ' -'
\}
endfunction
+6 -1
View File
@@ -2,12 +2,17 @@
" Description: Fixing Python imports with isort.
function! ale#fixers#isort#Fix(buffer) abort
let l:executable = ale#handlers#python#GetExecutable(a:buffer, 'isort')
if empty(l:executable)
return 0
endif
let l:config = ale#path#FindNearestFile(a:buffer, '.isort.cfg')
let l:config_options = !empty(l:config)
\ ? ' --settings-path ' . ale#Escape(l:config)
\ : ''
return {
\ 'command': 'isort' . l:config_options . ' -',
\ 'command': ale#Escape(l:executable) . l:config_options . ' -',
\}
endfunction
+6 -1
View File
@@ -2,12 +2,17 @@
" Description: Fixing Python files with yapf.
function! ale#fixers#yapf#Fix(buffer) abort
let l:executable = ale#handlers#python#GetExecutable(a:buffer, 'yapf')
if empty(l:executable)
return 0
endif
let l:config = ale#path#FindNearestFile(a:buffer, '.style.yapf')
let l:config_options = !empty(l:config)
\ ? ' --style ' . ale#Escape(l:config)
\ : ''
return {
\ 'command': 'yapf --no-local-style' . l:config_options,
\ 'command': ale#Escape(l:executable) . ' --no-local-style' . l:config_options,
\}
endfunction