diff options
author | Diego Henrique Oliveira <contato@diegoholiveira.com> | 2024-09-05 03:37:30 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-05 15:37:30 +0900 |
commit | a7ef1817b7aa06d0f80952ad530be87ad3c8f6e2 (patch) | |
tree | 537f36c4c8d5bdaeb10eb29ffc5bb8e18ef55065 /ale_linters/python | |
parent | 954682108d21b412561fb32e3fa766c7ee539984 (diff) | |
download | ale-a7ef1817b7aa06d0f80952ad530be87ad3c8f6e2.zip |
Improve support for python package manage: pipenv, poetry and uv (#4825)
Diffstat (limited to 'ale_linters/python')
-rw-r--r-- | ale_linters/python/bandit.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/flake8.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/flakehell.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/jedils.vim | 14 | ||||
-rw-r--r-- | ale_linters/python/mypy.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/prospector.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/pycln.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/pycodestyle.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/pydocstyle.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/pyflakes.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/pylama.vim | 10 | ||||
-rw-r--r-- | ale_linters/python/pylint.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/pylsp.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/pyre.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/pyright.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/refurb.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/ruff.vim | 10 | ||||
-rw-r--r-- | ale_linters/python/unimport.vim | 8 | ||||
-rw-r--r-- | ale_linters/python/vulture.vim | 20 |
19 files changed, 153 insertions, 21 deletions
diff --git a/ale_linters/python/bandit.vim b/ale_linters/python/bandit.vim index 9cfca7c0..ba48c3a8 100644 --- a/ale_linters/python/bandit.vim +++ b/ale_linters/python/bandit.vim @@ -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 ( @@ -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 @@ -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' \ : '' diff --git a/ale_linters/python/flake8.vim b/ale_linters/python/flake8.vim index 9950614a..12dca84a 100644 --- a/ale_linters/python/flake8.vim +++ b/ale_linters/python/flake8.vim @@ -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' @@ -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 @@ -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' \ : '' diff --git a/ale_linters/python/flakehell.vim b/ale_linters/python/flakehell.vim index ffe87e29..9ff0f18f 100644 --- a/ale_linters/python/flakehell.vim +++ b/ale_linters/python/flakehell.vim @@ -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' @@ -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 @@ -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' diff --git a/ale_linters/python/jedils.vim b/ale_linters/python/jedils.vim index e82abd1b..46b2896b 100644 --- a/ale_linters/python/jedils.vim +++ b/ale_linters/python/jedils.vim @@ -4,6 +4,8 @@ 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')) @@ -11,12 +13,22 @@ function! ale_linters#python#jedils#GetExecutable(buffer) abort 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 = '' diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim index 9d469a1a..586a4381 100644 --- a/ale_linters/python/mypy.vim +++ b/ale_linters/python/mypy.vim @@ -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')) @@ -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 @@ -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' \ : '' diff --git a/ale_linters/python/prospector.vim b/ale_linters/python/prospector.vim index 3623bda0..c40f25c5 100644 --- a/ale_linters/python/prospector.vim +++ b/ale_linters/python/prospector.vim @@ -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') @@ -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' \ : '' diff --git a/ale_linters/python/pycln.vim b/ale_linters/python/pycln.vim index 917a9757..774c6b04 100644 --- a/ale_linters/python/pycln.vim +++ b/ale_linters/python/pycln.vim @@ -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 @@ -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 @@ -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' \ : '' diff --git a/ale_linters/python/pycodestyle.vim b/ale_linters/python/pycodestyle.vim index 3fb94d69..bd3584b8 100644 --- a/ale_linters/python/pycodestyle.vim +++ b/ale_linters/python/pycodestyle.vim @@ -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')) @@ -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' \ : '' diff --git a/ale_linters/python/pydocstyle.vim b/ale_linters/python/pydocstyle.vim index ef0d818c..b012dd43 100644 --- a/ale_linters/python/pydocstyle.vim +++ b/ale_linters/python/pydocstyle.vim @@ -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')) @@ -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' \ : '' diff --git a/ale_linters/python/pyflakes.vim b/ale_linters/python/pyflakes.vim index 2567c533..fc0a3fa7 100644 --- a/ale_linters/python/pyflakes.vim +++ b/ale_linters/python/pyflakes.vim @@ -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')) @@ -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' \ : '' diff --git a/ale_linters/python/pylama.vim b/ale_linters/python/pylama.vim index 14f8071a..6555b409 100644 --- a/ale_linters/python/pylama.vim +++ b/ale_linters/python/pylama.vim @@ -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 @@ -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' \ : '' @@ -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' \ : '' diff --git a/ale_linters/python/pylint.vim b/ale_linters/python/pylint.vim index 2ce5376f..90aa5f1c 100644 --- a/ale_linters/python/pylint.vim +++ b/ale_linters/python/pylint.vim @@ -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 @@ -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 @@ -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' \ : '' diff --git a/ale_linters/python/pylsp.vim b/ale_linters/python/pylsp.vim index a1c31018..d3db6e82 100644 --- a/ale_linters/python/pylsp.vim +++ b/ale_linters/python/pylsp.vim @@ -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 @@ -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 @@ -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 = '' diff --git a/ale_linters/python/pyre.vim b/ale_linters/python/pyre.vim index 5e5786f9..177f1cb5 100644 --- a/ale_linters/python/pyre.vim +++ b/ale_linters/python/pyre.vim @@ -5,6 +5,7 @@ call ale#Set('python_pyre_executable', 'pyre') call ale#Set('python_pyre_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_pyre_auto_pipenv', 0) call ale#Set('python_pyre_auto_poetry', 0) +call ale#Set('python_pyre_auto_uv', 0) function! ale_linters#python#pyre#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyre_auto_pipenv')) @@ -17,12 +18,17 @@ function! ale_linters#python#pyre#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pyre_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_pyre', ['pyre']) endfunction function! ale_linters#python#pyre#GetCommand(buffer) abort let l:executable = ale_linters#python#pyre#GetExecutable(a:buffer) - let l:exec_args = (l:executable =~? 'pipenv\|poetry$' ? ' run pyre' : '') . ' persistent' + let l:exec_args = (l:executable =~? 'pipenv\|poetry\|uv$' ? ' run pyre' : '') . ' persistent' return ale#Escape(l:executable) . l:exec_args endfunction diff --git a/ale_linters/python/pyright.vim b/ale_linters/python/pyright.vim index e41f7f14..993ed075 100644 --- a/ale_linters/python/pyright.vim +++ b/ale_linters/python/pyright.vim @@ -3,6 +3,7 @@ call ale#Set('python_pyright_executable', 'pyright-langserver') call ale#Set('python_pyright_config', {}) call ale#Set('python_pyright_auto_pipenv', 0) call ale#Set('python_pyright_auto_poetry', 0) +call ale#Set('python_pyright_auto_uv', 0) " Force the cwd of the server to be the same as the project root to " fix issues with treating local files matching first or third party library @@ -59,12 +60,17 @@ function! ale_linters#python#pyright#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pyright_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_pyright', ['pyright-langserver']) endfunction function! ale_linters#python#pyright#GetCommand(buffer) abort let l:executable = ale_linters#python#pyright#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run pyright-langserver' \ : '' let l:env_string = '' diff --git a/ale_linters/python/refurb.vim b/ale_linters/python/refurb.vim index 1ae77b77..7f92948a 100644 --- a/ale_linters/python/refurb.vim +++ b/ale_linters/python/refurb.vim @@ -7,6 +7,7 @@ call ale#Set('python_refurb_use_global', get(g:, 'ale_use_global_executables', 0 call ale#Set('python_refurb_change_directory', 1) call ale#Set('python_refurb_auto_pipenv', 0) call ale#Set('python_refurb_auto_poetry', 0) +call ale#Set('python_refurb_auto_uv', 0) function! ale_linters#python#refurb#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_refurb_auto_pipenv')) @@ -19,6 +20,11 @@ function! ale_linters#python#refurb#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_refurb_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_refurb', ['refurb']) endfunction @@ -35,7 +41,7 @@ endfunction function! ale_linters#python#refurb#GetCommand(buffer) abort let l:executable = ale_linters#python#refurb#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run refurb' \ : '' diff --git a/ale_linters/python/ruff.vim b/ale_linters/python/ruff.vim index f30d42c0..25ae2d91 100644 --- a/ale_linters/python/ruff.vim +++ b/ale_linters/python/ruff.vim @@ -7,6 +7,7 @@ call ale#Set('python_ruff_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_ruff_change_directory', 1) call ale#Set('python_ruff_auto_pipenv', 0) call ale#Set('python_ruff_auto_poetry', 0) +call ale#Set('python_ruff_auto_uv', 0) call ale#fix#registry#Add('ruff', \ 'ale#fixers#ruff#Fix', @@ -25,6 +26,11 @@ function! ale_linters#python#ruff#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_ruff_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_ruff', ['ruff']) endfunction @@ -41,7 +47,7 @@ endfunction function! ale_linters#python#ruff#GetCommand(buffer, version) abort let l:executable = ale_linters#python#ruff#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run ruff' \ : '' @@ -49,7 +55,7 @@ function! ale_linters#python#ruff#GetCommand(buffer, version) abort let l:exec_args = l:exec_args \ . (ale#semver#GTE(a:version, [0, 3, 0]) ? ' check' : '') - " NOTE: ruff version `0.0.69` supports liniting input from stdin + " NOTE: ruff version `0.0.69` supports linting input from stdin " NOTE: ruff version `0.1.0` deprecates `--format text` return ale#Escape(l:executable) . l:exec_args . ' -q' \ . ' --no-fix' diff --git a/ale_linters/python/unimport.vim b/ale_linters/python/unimport.vim index 71fd80f0..06dbc436 100644 --- a/ale_linters/python/unimport.vim +++ b/ale_linters/python/unimport.vim @@ -5,6 +5,7 @@ call ale#Set('python_unimport_options', '') call ale#Set('python_unimport_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_unimport_auto_pipenv', 0) call ale#Set('python_unimport_auto_poetry', 0) +call ale#Set('python_unimport_auto_uv', 0) function! ale_linters#python#unimport#GetExecutable(buffer) abort if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_unimport_auto_pipenv')) @@ -17,12 +18,17 @@ function! ale_linters#python#unimport#GetExecutable(buffer) abort return 'poetry' endif + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_unimport_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_unimport', ['unimport']) endfunction function! ale_linters#python#unimport#GetCommand(buffer) abort let l:executable = ale_linters#python#unimport#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run unimport' \ : '' diff --git a/ale_linters/python/vulture.vim b/ale_linters/python/vulture.vim index a7ba1860..2ac05e43 100644 --- a/ale_linters/python/vulture.vim +++ b/ale_linters/python/vulture.vim @@ -5,6 +5,9 @@ call ale#Set('python_vulture_executable', 'vulture') call ale#Set('python_vulture_options', '') call ale#Set('python_vulture_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('python_vulture_change_directory', 1) +call ale#Set('python_vulture_auto_pipenv', 0) +call ale#Set('python_vulture_auto_poetry', 0) +call ale#Set('python_vulture_auto_uv', 0) " The directory to change to before running vulture function! s:GetDir(buffer) abort @@ -16,6 +19,21 @@ function! s:GetDir(buffer) abort endfunction function! ale_linters#python#vulture#GetExecutable(buffer) abort + if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_vulture_auto_pipenv')) + \ && ale#python#PipenvPresent(a:buffer) + return 'pipenv' + endif + + if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_vulture_auto_poetry')) + \ && ale#python#PoetryPresent(a:buffer) + return 'poetry' + endif + + if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_vulture_auto_uv')) + \ && ale#python#UvPresent(a:buffer) + return 'uv' + endif + return ale#python#FindExecutable(a:buffer, 'python_vulture', ['vulture']) endfunction @@ -29,7 +47,7 @@ endfunction function! ale_linters#python#vulture#GetCommand(buffer) abort let l:executable = ale_linters#python#vulture#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry$' + let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' \ ? ' run vulture' \ : '' let l:lint_dest = ale#Var(a:buffer, 'python_vulture_change_directory') |