mirror of https://github.com/dense-analysis/ale
Fix python linting/formatting error when in virtual environment (#4865)
Python fixers and linters were failing when vim is running in a virtual environment that's located in a path containing text `poetry`. The cause of this was the regular expression `poetry\|pipenv\|uv$` which matches `poetry` and `pipenv` if they appear anywhere in the virtualenv path.
This commit is contained in:
parent
898638abe5
commit
5cc6b933b1
|
@ -45,7 +45,7 @@ function! ale_linters#python#bandit#GetCommand(buffer) abort
|
|||
endif
|
||||
endif
|
||||
|
||||
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run bandit'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -74,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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run flake8'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -74,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\|uv$')
|
||||
if (l:executable =~? '\(pipenv\|poetry\|uv\)$')
|
||||
let l:exec_args = ' run flakehell'
|
||||
elseif (l:executable is? 'python')
|
||||
let l:exec_args = ' -m flakehell'
|
||||
|
|
|
@ -28,7 +28,7 @@ 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\|poetry\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run jedi-language-server'
|
||||
\ : ''
|
||||
let l:env_string = ''
|
||||
|
|
|
@ -49,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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run mypy'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ 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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run prospector'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -42,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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run pycln'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ 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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run pycodestyle'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ 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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run pydocstyle'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ 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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run pyflakes'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ 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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run pylama'
|
||||
\ : ''
|
||||
|
||||
|
@ -59,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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run pylama'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -44,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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run pylint'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -43,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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run pylsp'
|
||||
\ : ''
|
||||
let l:env_string = ''
|
||||
|
|
|
@ -28,7 +28,7 @@ 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\|uv$' ? ' run pyre' : '') . ' persistent'
|
||||
let l:exec_args = (l:executable =~? '\(pipenv\|poetry\|uv\)$' ? ' run pyre' : '') . ' persistent'
|
||||
|
||||
return ale#Escape(l:executable) . l:exec_args
|
||||
endfunction
|
||||
|
|
|
@ -70,7 +70,7 @@ 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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run pyright-langserver'
|
||||
\ : ''
|
||||
let l:env_string = ''
|
||||
|
|
|
@ -41,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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run refurb'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -47,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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run ruff'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ 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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run unimport'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -47,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\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run vulture'
|
||||
\ : ''
|
||||
let l:lint_dest = ale#Var(a:buffer, 'python_vulture_change_directory')
|
||||
|
|
|
@ -30,7 +30,7 @@ endfunction
|
|||
function! ale#fixers#autoflake#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#autoflake#GetExecutable(a:buffer)
|
||||
|
||||
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run autoflake'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ endfunction
|
|||
function! ale#fixers#autoimport#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#autoimport#GetExecutable(a:buffer)
|
||||
|
||||
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run autoimport'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ endfunction
|
|||
function! ale#fixers#autopep8#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#autopep8#GetExecutable(a:buffer)
|
||||
|
||||
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run autopep8'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ function! ale#fixers#black#Fix(buffer) abort
|
|||
let l:executable = ale#fixers#black#GetExecutable(a:buffer)
|
||||
let l:cmd = [ale#Escape(l:executable)]
|
||||
|
||||
if l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
if l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
call extend(l:cmd, ['run', 'black'])
|
||||
endif
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ function! ale#fixers#isort#GetCmd(buffer) abort
|
|||
let l:executable = ale#fixers#isort#GetExecutable(a:buffer)
|
||||
let l:cmd = [ale#Escape(l:executable)]
|
||||
|
||||
if l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
if l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
call extend(l:cmd, ['run', 'isort'])
|
||||
endif
|
||||
|
||||
|
@ -42,7 +42,7 @@ function! ale#fixers#isort#FixForVersion(buffer, version) abort
|
|||
let l:executable = ale#fixers#isort#GetExecutable(a:buffer)
|
||||
let l:cmd = [ale#Escape(l:executable)]
|
||||
|
||||
if l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
if l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
call extend(l:cmd, ['run', 'isort'])
|
||||
endif
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ endfunction
|
|||
|
||||
function! ale#fixers#pycln#GetCommand(buffer) abort
|
||||
let l:executable = ale#fixers#pycln#GetExecutable(a:buffer)
|
||||
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run pycln'
|
||||
\ : ''
|
||||
|
||||
|
@ -53,7 +53,7 @@ function! ale#fixers#pycln#FixForVersion(buffer, version) abort
|
|||
let l:executable = ale#fixers#pycln#GetExecutable(a:buffer)
|
||||
let l:cmd = [ale#Escape(l:executable)]
|
||||
|
||||
if l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
if l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
call extend(l:cmd, ['run', 'pycln'])
|
||||
endif
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ function! ale#fixers#pyflyby#Fix(buffer) abort
|
|||
let l:executable = ale#fixers#pyflyby#GetExecutable(a:buffer)
|
||||
let l:cmd = [ale#Escape(l:executable)]
|
||||
|
||||
if l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
if l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
call extend(l:cmd, ['run', 'tidy-imports'])
|
||||
endif
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ endfunction
|
|||
function! ale#fixers#reorder_python_imports#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#reorder_python_imports#GetExecutable(a:buffer)
|
||||
|
||||
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run reorder-python-imports'
|
||||
\ : ''
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ endfunction
|
|||
|
||||
function! ale#fixers#ruff#GetCommand(buffer) abort
|
||||
let l:executable = ale#fixers#ruff#GetExecutable(a:buffer)
|
||||
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run ruff'
|
||||
\ : ''
|
||||
|
||||
|
@ -52,7 +52,7 @@ function! ale#fixers#ruff#FixForVersion(buffer, version) abort
|
|||
let l:executable = ale#fixers#ruff#GetExecutable(a:buffer)
|
||||
let l:cmd = [ale#Escape(l:executable)]
|
||||
|
||||
if l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
if l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
call extend(l:cmd, ['run', 'ruff'])
|
||||
endif
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ endfunction
|
|||
|
||||
function! ale#fixers#ruff_format#GetCommand(buffer) abort
|
||||
let l:executable = ale#fixers#ruff_format#GetExecutable(a:buffer)
|
||||
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run ruff'
|
||||
\ : ''
|
||||
|
||||
|
@ -52,7 +52,7 @@ function! ale#fixers#ruff_format#Fix(buffer) abort
|
|||
let l:executable = ale#fixers#ruff_format#GetExecutable(a:buffer)
|
||||
let l:cmd = [ale#Escape(l:executable)]
|
||||
|
||||
if l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
if l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
call extend(l:cmd, ['run', 'ruff'])
|
||||
endif
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ endfunction
|
|||
function! ale#fixers#yapf#Fix(buffer) abort
|
||||
let l:executable = ale#fixers#yapf#GetExecutable(a:buffer)
|
||||
|
||||
let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$'
|
||||
let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
|
||||
\ ? ' run yapf'
|
||||
\ : ''
|
||||
|
||||
|
|
Loading…
Reference in New Issue