add unimport fixer (#5068)

This commit is contained in:
FouMalade
2025-11-22 13:14:57 +01:00
committed by GitHub
parent 1f0f9ef28d
commit 5f286eb909
3 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
Before:
call ale#assert#SetUpFixerTest('python', 'unimport')
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
After:
call ale#assert#TearDownFixerTest()
unlet! b:bin_dir
Execute(The unimport callback should return the correct default values):
call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
AssertFixer
\ {
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/unimport')),
\ }
Execute(Pipenv is detected when python_unimport_auto_pipenv is set):
let g:ale_python_unimport_auto_pipenv = 1
call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
AssertFixer
\ {
\ 'command': ale#Escape('pipenv') . ' run unimport'
\ }
Execute(Poetry is detected when python_unimport_auto_poetry is set):
let g:ale_python_unimport_auto_poetry = 1
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
AssertFixer
\ {
\ 'command': ale#Escape('poetry') . ' run unimport'
\ }
Execute(uv is detected when python_unimport_auto_uv is set):
let g:ale_python_unimport_auto_uv = 1
call ale#test#SetFilename('../test-files/python/uv/whatever.py')
AssertFixer
\ {
\ 'command': ale#Escape('uv') . ' run unimport'
\ }