summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Bourton <53911430+TBourton@users.noreply.github.com>2024-07-02 08:43:02 +0100
committerGitHub <noreply@github.com>2024-07-02 16:43:02 +0900
commita35fa4d732220914d620deccbc8ef68fa1bff96f (patch)
treeea96b13bd241c55d22c3a8955e1fe5fa9505ac43
parenta0ad5f938ac0b7a1b74c45fa56529f3e3f3342e6 (diff)
downloadale-a35fa4d732220914d620deccbc8ef68fa1bff96f.zip
When ruff version is >=0.5.0 use 'ruff check <path>' instead of 'ruff <path>' (#4802)
-rw-r--r--autoload/ale/fixers/ruff.vim5
-rw-r--r--test/fixers/test_ruff_fixer_callback.vader14
2 files changed, 19 insertions, 0 deletions
diff --git a/autoload/ale/fixers/ruff.vim b/autoload/ale/fixers/ruff.vim
index 56bcf3df..275f79b0 100644
--- a/autoload/ale/fixers/ruff.vim
+++ b/autoload/ale/fixers/ruff.vim
@@ -50,6 +50,11 @@ function! ale#fixers#ruff#FixForVersion(buffer, version) abort
call extend(l:cmd, ['run', 'ruff'])
endif
+ " NOTE: ruff 0.5.0 removes `ruff <path>` in favor of `ruff check <path>`
+ if ale#semver#GTE(a:version, [0, 5, 0])
+ call extend(l:cmd, ['check'])
+ endif
+
let l:options = ale#Var(a:buffer, 'python_ruff_options')
if !empty(l:options)
diff --git a/test/fixers/test_ruff_fixer_callback.vader b/test/fixers/test_ruff_fixer_callback.vader
index 68c7a942..abe5860e 100644
--- a/test/fixers/test_ruff_fixer_callback.vader
+++ b/test/fixers/test_ruff_fixer_callback.vader
@@ -73,6 +73,20 @@ Execute(The ruff callback should respect custom options):
\ . ' --ignore F401 -q --stdin-filename '. fname . ' --fix -',
\ }
+Execute(The ruff callback should use ruff check for 0.5.0):
+ let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
+
+ silent execute 'file ' . fnameescape(file_path)
+
+ let fname = ale#Escape(ale#path#Simplify(file_path))
+
+ GivenCommandOutput ['ruff 0.5.0']
+ AssertFixer
+ \ {
+ \ 'cwd': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir'),
+ \ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/ruff')) . ' check --stdin-filename ' . fname . ' --fix -',
+ \ }
+
Execute(Pipenv is detected when python_ruff_auto_pipenv is set):
let g:ale_python_ruff_auto_pipenv = 1
let g:ale_python_ruff_change_directory = 0