diff options
author | Horacio Sanson <hsanson@gmail.com> | 2021-10-16 14:02:58 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-16 14:02:58 +0900 |
commit | 16898417e68ffb6034b2a6de0c1b25502bd846d8 (patch) | |
tree | fcf7d1a64cb923135bf457b29362a626a9a9f3c7 /autoload | |
parent | c7e3f1a0dd447eeafcbbd158974860c1918dbdd5 (diff) | |
download | ale-16898417e68ffb6034b2a6de0c1b25502bd846d8.zip |
Fix 3941 - add version check to isort fixer (#3942)
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/fixers/isort.vim | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/autoload/ale/fixers/isort.vim b/autoload/ale/fixers/isort.vim index 082e77ec..6eb6a67c 100644 --- a/autoload/ale/fixers/isort.vim +++ b/autoload/ale/fixers/isort.vim @@ -21,7 +21,18 @@ function! ale#fixers#isort#GetExecutable(buffer) abort return ale#python#FindExecutable(a:buffer, 'python_isort', ['isort']) endfunction -function! ale#fixers#isort#Fix(buffer) abort +function! ale#fixers#isort#GetCmd(buffer) abort + let l:executable = ale#fixers#isort#GetExecutable(a:buffer) + let l:cmd = [ale#Escape(l:executable)] + + if l:executable =~? 'pipenv\|poetry$' + call extend(l:cmd, ['run', 'isort']) + endif + + return join(l:cmd, ' ') +endfunction + +function! ale#fixers#isort#FixForVersion(buffer, version) abort let l:executable = ale#fixers#isort#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] @@ -29,7 +40,9 @@ function! ale#fixers#isort#Fix(buffer) abort call extend(l:cmd, ['run', 'isort']) endif - call add(l:cmd, '--filename %s') + if ale#semver#GTE(a:version, [5, 7, 0]) + call add(l:cmd, '--filename %s') + endif let l:options = ale#Var(a:buffer, 'python_isort_options') @@ -41,6 +54,18 @@ function! ale#fixers#isort#Fix(buffer) abort return { \ 'cwd': '%s:h', - \ 'command': join(l:cmd, ' ') + \ 'command': join(l:cmd, ' '), \} endfunction + +function! ale#fixers#isort#Fix(buffer) abort + let l:executable = ale#fixers#isort#GetExecutable(a:buffer) + let l:command = ale#fixers#isort#GetCmd(a:buffer) . ale#Pad('--version') + + return ale#semver#RunWithVersionCheck( + \ a:buffer, + \ l:executable, + \ l:command, + \ function('ale#fixers#isort#FixForVersion'), + \) +endfunction |