Skip to content

Commit

Permalink
fix(ale_linters: python: ruff): add --stdin-filename if version > 0.0…
Browse files Browse the repository at this point in the history
  • Loading branch information
actionless authored and mnikulin committed Nov 12, 2023
1 parent 52ff7e0 commit d1be9be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ale_linters/python/ruff.vim
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function! ale_linters#python#ruff#GetCommand(buffer, version) abort
return ale#Escape(l:executable) . l:exec_args
\ . ale#Pad(ale#Var(a:buffer, 'python_ruff_options'))
\ . ' --format text'
\ . (ale#semver#GTE(a:version, [0, 0, 69]) ? ' -' : ' %s')
\ . (ale#semver#GTE(a:version, [0, 0, 69]) ? ' --stdin-filename %s -' : ' %s')
endfunction

function! ale_linters#python#ruff#Handle(buffer, lines) abort
Expand Down
12 changes: 6 additions & 6 deletions test/linter/test_ruff.vader
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Before:
call ale#assert#SetUpLinterTest('python', 'ruff')

let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
let b:command_tail = ' --format text -'
let b:command_tail = ' --format text --stdin-filename %s -'

GivenCommandOutput ['ruff 0.0.83']

Expand All @@ -26,7 +26,7 @@ Execute(ruff should run with the file path of buffer in old versions):
GivenCommandOutput ['ruff 0.0.68']

AssertLinterCwd expand('%:p:h')
AssertLinter 'ruff', ale#Escape('ruff') . b:command_tail[:-3] . ' %s'
AssertLinter 'ruff', ale#Escape('ruff') . b:command_tail[:-23] . ' %s'

Execute(ruff should run with the stdin in new enough versions):
GivenCommandOutput ['ruff 0.0.83']
Expand Down Expand Up @@ -79,27 +79,27 @@ Execute(Setting executable to 'pipenv' appends 'run ruff'):
let g:ale_python_ruff_use_global = 1

AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run ruff'
\ . ' --format text -'
\ . b:command_tail

Execute(Pipenv is detected when python_ruff_auto_pipenv is set):
let g:ale_python_ruff_auto_pipenv = 1
call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')

AssertLinterCwd expand('%:p:h')
AssertLinter 'pipenv', ale#Escape('pipenv') . ' run ruff'
\ . ' --format text -'
\ . b:command_tail

Execute(Setting executable to 'poetry' appends 'run ruff'):
let g:ale_python_ruff_executable = 'path/to/poetry'
let g:ale_python_ruff_use_global = 1

AssertLinter 'path/to/poetry', ale#Escape('path/to/poetry') . ' run ruff'
\ . ' --format text -'
\ . b:command_tail

Execute(poetry is detected when python_ruff_auto_poetry is set):
let g:ale_python_ruff_auto_poetry = 1
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')

AssertLinterCwd expand('%:p:h')
AssertLinter 'poetry', ale#Escape('poetry') . ' run ruff'
\ . ' --format text -'
\ . b:command_tail

0 comments on commit d1be9be

Please sign in to comment.