fixes ruff#GetCommand checking packagemanger verison and not ruff (#5026)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled

This commit is contained in:
Kyle Behrens
2025-08-14 07:57:46 -04:00
committed by GitHub
parent 822d9a1bf3
commit 37e64b5caf

View File

@@ -34,6 +34,22 @@ function! ale_linters#python#ruff#GetExecutable(buffer) abort
return ale#python#FindExecutable(a:buffer, 'python_ruff', ['ruff'])
endfunction
function! ale_linters#python#ruff#RunWithVersionCheck(buffer) abort
let l:executable = ale_linters#python#ruff#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
\ ? ' run ruff'
\ : ''
let l:command = ale#Escape(l:executable) . l:exec_args . ' --version'
return ale#semver#RunWithVersionCheck(
\ a:buffer,
\ l:executable,
\ l:command,
\ function('ale_linters#python#ruff#GetCommand'),
\)
endfunction
function! ale_linters#python#ruff#GetCwd(buffer) abort
if ale#Var(a:buffer, 'python_ruff_change_directory')
" Run from project root if found, else from buffer dir.
@@ -110,12 +126,7 @@ call ale#linter#Define('python', {
\ 'name': 'ruff',
\ 'executable': function('ale_linters#python#ruff#GetExecutable'),
\ 'cwd': function('ale_linters#python#ruff#GetCwd'),
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
\ buffer,
\ ale_linters#python#ruff#GetExecutable(buffer),
\ '%e --version',
\ function('ale_linters#python#ruff#GetCommand'),
\ )},
\ 'command': function('ale_linters#python#ruff#RunWithVersionCheck'),
\ 'callback': 'ale_linters#python#ruff#Handle',
\ 'output_stream': 'both',
\ 'read_buffer': 1,