Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve support for python package manage: pipenv, poetry and uv #4825

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ale_linters/python/bandit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ call ale#Set('python_bandit_use_config', 1)
call ale#Set('python_bandit_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_bandit_auto_pipenv', 0)
call ale#Set('python_bandit_auto_poetry', 0)
call ale#Set('python_bandit_auto_uv', 0)

function! ale_linters#python#bandit#GetExecutable(buffer) abort
if (
Expand All @@ -23,6 +24,11 @@ function! ale_linters#python#bandit#GetExecutable(buffer) abort
return 'poetry'
endif

if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_bandit_auto_uv'))
\ && ale#python#UvPresent(a:buffer)
return 'uv'
endif

return ale#python#FindExecutable(a:buffer, 'python_bandit', ['bandit'])
endfunction

Expand All @@ -39,7 +45,7 @@ function! ale_linters#python#bandit#GetCommand(buffer) abort
endif
endif

let l:exec_args = l:executable =~? 'pipenv\|poetry$'
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
\ ? ' run bandit'
\ : ''

Expand Down
8 changes: 7 additions & 1 deletion ale_linters/python/flake8.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ call ale#Set('python_flake8_use_global', get(g:, 'ale_use_global_executables', 0
call ale#Set('python_flake8_change_directory', 'project')
call ale#Set('python_flake8_auto_pipenv', 0)
call ale#Set('python_flake8_auto_poetry', 0)
call ale#Set('python_flake8_auto_uv', 0)

function! s:UsingModule(buffer) abort
return ale#Var(a:buffer, 'python_flake8_options') =~# ' *-m flake8'
Expand All @@ -23,6 +24,11 @@ function! ale_linters#python#flake8#GetExecutable(buffer) abort
return 'poetry'
endif

if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_flake8_auto_uv'))
\ && ale#python#UvPresent(a:buffer)
return 'uv'
endif

if !s:UsingModule(a:buffer)
return ale#python#FindExecutable(a:buffer, 'python_flake8', ['flake8'])
endif
Expand Down Expand Up @@ -68,7 +74,7 @@ endfunction
function! ale_linters#python#flake8#GetCommand(buffer, version) abort
let l:executable = ale_linters#python#flake8#GetExecutable(a:buffer)

let l:exec_args = l:executable =~? 'pipenv\|poetry$'
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
\ ? ' run flake8'
\ : ''

Expand Down
8 changes: 7 additions & 1 deletion ale_linters/python/flakehell.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ call ale#Set('python_flakehell_use_global', get(g:, 'ale_use_global_executables'
call ale#Set('python_flakehell_change_directory', 'project')
call ale#Set('python_flakehell_auto_pipenv', 0)
call ale#Set('python_flakehell_auto_poetry', 0)
call ale#Set('python_flakehell_auto_uv', 0)

function! s:UsingModule(buffer) abort
return ale#Var(a:buffer, 'python_flakehell_executable') is? 'python'
Expand All @@ -23,6 +24,11 @@ function! ale_linters#python#flakehell#GetExecutable(buffer) abort
return 'poetry'
endif

if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_flakehell_auto_uv'))
\ && ale#python#UvPresent(a:buffer)
return 'uv'
endif

if !s:UsingModule(a:buffer)
return ale#python#FindExecutable(a:buffer, 'python_flakehell', ['flakehell'])
endif
Expand Down Expand Up @@ -68,7 +74,7 @@ endfunction
function! ale_linters#python#flakehell#GetCommand(buffer, version) abort
let l:executable = ale_linters#python#flakehell#GetExecutable(a:buffer)

if (l:executable =~? 'pipenv\|poetry$')
if (l:executable =~? 'pipenv\|poetry\|uv$')
let l:exec_args = ' run flakehell'
elseif (l:executable is? 'python')
let l:exec_args = ' -m flakehell'
Expand Down
14 changes: 13 additions & 1 deletion ale_linters/python/jedils.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,31 @@
call ale#Set('python_jedils_executable', 'jedi-language-server')
call ale#Set('python_jedils_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_jedils_auto_pipenv', 0)
call ale#Set('python_jedils_auto_poetry', 0)
call ale#Set('python_jedils_auto_uv', 0)

function! ale_linters#python#jedils#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_jedils_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif

if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_jedils_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
endif

if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_jedils_auto_uv'))
\ && ale#python#UvPresent(a:buffer)
return 'uv'
endif

return ale#python#FindExecutable(a:buffer, 'python_jedils', ['jedi-language-server'])
endfunction

function! ale_linters#python#jedils#GetCommand(buffer) abort
let l:executable = ale_linters#python#jedils#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv$'
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
\ ? ' run jedi-language-server'
\ : ''
let l:env_string = ''
Expand Down
8 changes: 7 additions & 1 deletion ale_linters/python/mypy.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ call ale#Set('python_mypy_options', '')
call ale#Set('python_mypy_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_mypy_auto_pipenv', 0)
call ale#Set('python_mypy_auto_poetry', 0)
call ale#Set('python_mypy_auto_uv', 0)

function! ale_linters#python#mypy#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_mypy_auto_pipenv'))
Expand All @@ -20,6 +21,11 @@ function! ale_linters#python#mypy#GetExecutable(buffer) abort
return 'poetry'
endif

if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_mypy_auto_uv'))
\ && ale#python#UvPresent(a:buffer)
return 'uv'
endif

return ale#python#FindExecutable(a:buffer, 'python_mypy', ['mypy'])
endfunction

Expand All @@ -43,7 +49,7 @@ endfunction

function! ale_linters#python#mypy#GetCommand(buffer) abort
let l:executable = ale_linters#python#mypy#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
\ ? ' run mypy'
\ : ''

Expand Down
8 changes: 7 additions & 1 deletion ale_linters/python/prospector.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

call ale#Set('python_prospector_auto_pipenv', 0)
call ale#Set('python_prospector_auto_poetry', 0)
call ale#Set('python_prospector_auto_uv', 0)

let g:ale_python_prospector_executable =
\ get(g:, 'ale_python_prospector_executable', 'prospector')
Expand All @@ -23,13 +24,18 @@ function! ale_linters#python#prospector#GetExecutable(buffer) abort
return 'poetry'
endif

if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_prospector_auto_uv'))
\ && ale#python#UvPresent(a:buffer)
return 'uv'
endif

return ale#python#FindExecutable(a:buffer, 'python_prospector', ['prospector'])
endfunction

function! ale_linters#python#prospector#GetCommand(buffer) abort
let l:executable = ale_linters#python#prospector#GetExecutable(a:buffer)

let l:exec_args = l:executable =~? 'pipenv\|poetry$'
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
\ ? ' run prospector'
\ : ''

Expand Down
8 changes: 7 additions & 1 deletion ale_linters/python/pycln.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ call ale#Set('python_pycln_use_global', get(g:, 'ale_use_global_executables', 0)
call ale#Set('python_pycln_change_directory', 1)
call ale#Set('python_pycln_auto_pipenv', 0)
call ale#Set('python_pycln_auto_poetry', 0)
call ale#Set('python_pycln_auto_uv', 0)
call ale#Set('python_pycln_config_file', '')

function! ale_linters#python#pycln#GetExecutable(buffer) abort
Expand All @@ -20,6 +21,11 @@ function! ale_linters#python#pycln#GetExecutable(buffer) abort
return 'poetry'
endif

if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pycln_auto_uv'))
\ && ale#python#UvPresent(a:buffer)
return 'uv'
endif

return ale#python#FindExecutable(a:buffer, 'python_pycln', ['pycln'])
endfunction

Expand All @@ -36,7 +42,7 @@ endfunction

function! ale_linters#python#pycln#GetCommand(buffer, version) abort
let l:executable = ale_linters#python#pycln#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
\ ? ' run pycln'
\ : ''

Expand Down
8 changes: 7 additions & 1 deletion ale_linters/python/pycodestyle.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ call ale#Set('python_pycodestyle_options', '')
call ale#Set('python_pycodestyle_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_pycodestyle_auto_pipenv', 0)
call ale#Set('python_pycodestyle_auto_poetry', 0)
call ale#Set('python_pycodestyle_auto_uv', 0)

function! ale_linters#python#pycodestyle#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pycodestyle_auto_pipenv'))
Expand All @@ -18,13 +19,18 @@ function! ale_linters#python#pycodestyle#GetExecutable(buffer) abort
return 'poetry'
endif

if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pycodestyle_auto_uv'))
\ && ale#python#UvPresent(a:buffer)
return 'uv'
endif

return ale#python#FindExecutable(a:buffer, 'python_pycodestyle', ['pycodestyle'])
endfunction

function! ale_linters#python#pycodestyle#GetCommand(buffer) abort
let l:executable = ale_linters#python#pycodestyle#GetExecutable(a:buffer)

let l:exec_args = l:executable =~? 'pipenv\|poetry$'
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
\ ? ' run pycodestyle'
\ : ''

Expand Down
8 changes: 7 additions & 1 deletion ale_linters/python/pydocstyle.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ call ale#Set('python_pydocstyle_options', '')
call ale#Set('python_pydocstyle_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_pydocstyle_auto_pipenv', 0)
call ale#Set('python_pydocstyle_auto_poetry', 0)
call ale#Set('python_pydocstyle_auto_uv', 0)

function! ale_linters#python#pydocstyle#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pydocstyle_auto_pipenv'))
Expand All @@ -18,12 +19,17 @@ function! ale_linters#python#pydocstyle#GetExecutable(buffer) abort
return 'poetry'
endif

if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pydocstyle_auto_uv'))
\ && ale#python#UvPresent(a:buffer)
return 'uv'
endif

return ale#python#FindExecutable(a:buffer, 'python_pydocstyle', ['pydocstyle'])
endfunction

function! ale_linters#python#pydocstyle#GetCommand(buffer) abort
let l:executable = ale_linters#python#pydocstyle#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
\ ? ' run pydocstyle'
\ : ''

Expand Down
8 changes: 7 additions & 1 deletion ale_linters/python/pyflakes.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ call ale#Set('python_pyflakes_executable', 'pyflakes')
call ale#Set('python_pyflakes_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_pyflakes_auto_pipenv', 0)
call ale#Set('python_pyflakes_auto_poetry', 0)
call ale#Set('python_pyflakes_auto_uv', 0)

function! ale_linters#python#pyflakes#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyflakes_auto_pipenv'))
Expand All @@ -17,13 +18,18 @@ function! ale_linters#python#pyflakes#GetExecutable(buffer) abort
return 'poetry'
endif

if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pyflakes_auto_uv'))
\ && ale#python#UvPresent(a:buffer)
return 'uv'
endif

return ale#python#FindExecutable(a:buffer, 'python_pyflakes', ['pyflakes'])
endfunction

function! ale_linters#python#pyflakes#GetCommand(buffer) abort
let l:executable = ale_linters#python#pyflakes#GetExecutable(a:buffer)

let l:exec_args = l:executable =~? 'pipenv\|poetry$'
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
\ ? ' run pyflakes'
\ : ''

Expand Down
10 changes: 8 additions & 2 deletions ale_linters/python/pylama.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ call ale#Set('python_pylama_options', '')
call ale#Set('python_pylama_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_pylama_auto_pipenv', 0)
call ale#Set('python_pylama_auto_poetry', 0)
call ale#Set('python_pylama_auto_uv', 0)
call ale#Set('python_pylama_change_directory', 1)

function! ale_linters#python#pylama#GetExecutable(buffer) abort
Expand All @@ -19,12 +20,17 @@ function! ale_linters#python#pylama#GetExecutable(buffer) abort
return 'poetry'
endif

if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pylama_auto_uv'))
\ && ale#python#UvPresent(a:buffer)
return 'uv'
endif

return ale#python#FindExecutable(a:buffer, 'python_pylama', ['pylama'])
endfunction

function! ale_linters#python#pylama#RunWithVersionCheck(buffer) abort
let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
\ ? ' run pylama'
\ : ''

Expand Down Expand Up @@ -53,7 +59,7 @@ endfunction

function! ale_linters#python#pylama#GetCommand(buffer, version) abort
let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
\ ? ' run pylama'
\ : ''

Expand Down
8 changes: 7 additions & 1 deletion ale_linters/python/pylint.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ call ale#Set('python_pylint_use_global', get(g:, 'ale_use_global_executables', 0
call ale#Set('python_pylint_change_directory', 1)
call ale#Set('python_pylint_auto_pipenv', 0)
call ale#Set('python_pylint_auto_poetry', 0)
call ale#Set('python_pylint_auto_uv', 0)
call ale#Set('python_pylint_use_msg_id', 0)

function! ale_linters#python#pylint#GetExecutable(buffer) abort
Expand All @@ -20,6 +21,11 @@ function! ale_linters#python#pylint#GetExecutable(buffer) abort
return 'poetry'
endif

if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pylint_auto_uv'))
\ && ale#python#UvPresent(a:buffer)
return 'uv'
endif

return ale#python#FindExecutable(a:buffer, 'python_pylint', ['pylint'])
endfunction

Expand All @@ -38,7 +44,7 @@ endfunction

function! ale_linters#python#pylint#GetCommand(buffer, version) abort
let l:executable = ale_linters#python#pylint#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
\ ? ' run pylint'
\ : ''

Expand Down
8 changes: 7 additions & 1 deletion ale_linters/python/pylsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ call ale#Set('python_pylsp_options', '')
call ale#Set('python_pylsp_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_pylsp_auto_pipenv', 0)
call ale#Set('python_pylsp_auto_poetry', 0)
call ale#Set('python_pylsp_auto_uv', 0)
call ale#Set('python_pylsp_config', {})

function! ale_linters#python#pylsp#GetExecutable(buffer) abort
Expand All @@ -19,6 +20,11 @@ function! ale_linters#python#pylsp#GetExecutable(buffer) abort
return 'poetry'
endif

if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pylsp_auto_uv'))
\ && ale#python#UvPresent(a:buffer)
return 'uv'
endif

return ale#python#FindExecutable(a:buffer, 'python_pylsp', ['pylsp'])
endfunction

Expand All @@ -37,7 +43,7 @@ endfunction

function! ale_linters#python#pylsp#GetCommand(buffer) abort
let l:executable = ale_linters#python#pylsp#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
\ ? ' run pylsp'
\ : ''
let l:env_string = ''
Expand Down
Loading