Python support poetry (#3834)

* Add poetry support to python linters and black fixer.

* Update python.vim to detect poetry project.

* Update ale.vim, add an option for poetry `g:ale_python_auto_poetry`.

* Update ale-python.txt, add poetry support.

* Add and update poetry related tests.

Co-authored-by: unc0 <unc0@users.noreply.github.com>
This commit is contained in:
Daniel Roseman 2021-07-25 05:39:05 +01:00 committed by GitHub
parent 530b38de34
commit 7d8fb2ba17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 414 additions and 16 deletions

View File

@ -6,6 +6,7 @@ call ale#Set('python_bandit_options', '')
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)
function! ale_linters#python#bandit#GetExecutable(buffer) abort
if (
@ -15,6 +16,13 @@ function! ale_linters#python#bandit#GetExecutable(buffer) abort
return 'pipenv'
endif
if (
\ ale#Var(a:buffer, 'python_auto_poetry')
\ || ale#Var(a:buffer, 'python_bandit_auto_poetry')
\) && ale#python#PoetryPresent(a:buffer)
return 'poetry'
endif
return ale#python#FindExecutable(a:buffer, 'python_bandit', ['bandit'])
endfunction
@ -31,7 +39,7 @@ function! ale_linters#python#bandit#GetCommand(buffer) abort
endif
endif
let l:exec_args = l:executable =~? 'pipenv$'
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run bandit'
\ : ''

View File

@ -6,6 +6,7 @@ call ale#Set('python_flake8_options', '')
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)
function! s:UsingModule(buffer) abort
return ale#Var(a:buffer, 'python_flake8_options') =~# ' *-m flake8'
@ -17,6 +18,11 @@ function! ale_linters#python#flake8#GetExecutable(buffer) abort
return 'pipenv'
endif
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_flake8_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
endif
if !s:UsingModule(a:buffer)
return ale#python#FindExecutable(a:buffer, 'python_flake8', ['flake8'])
endif
@ -62,7 +68,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$'
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run flake8'
\ : ''

View File

@ -7,6 +7,7 @@ call ale#Set('python_mypy_show_notes', 1)
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)
function! ale_linters#python#mypy#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_mypy_auto_pipenv'))
@ -14,6 +15,11 @@ function! ale_linters#python#mypy#GetExecutable(buffer) abort
return 'pipenv'
endif
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_mypy_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
endif
return ale#python#FindExecutable(a:buffer, 'python_mypy', ['mypy'])
endfunction
@ -37,7 +43,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$'
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run mypy'
\ : ''

View File

@ -2,6 +2,7 @@
" Description: prospector linter python files
call ale#Set('python_prospector_auto_pipenv', 0)
call ale#Set('python_prospector_auto_poetry', 0)
let g:ale_python_prospector_executable =
\ get(g:, 'ale_python_prospector_executable', 'prospector')
@ -17,13 +18,18 @@ function! ale_linters#python#prospector#GetExecutable(buffer) abort
return 'pipenv'
endif
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_prospector_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
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$'
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run prospector'
\ : ''

View File

@ -5,6 +5,7 @@ call ale#Set('python_pycodestyle_executable', 'pycodestyle')
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)
function! ale_linters#python#pycodestyle#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pycodestyle_auto_pipenv'))
@ -12,13 +13,18 @@ function! ale_linters#python#pycodestyle#GetExecutable(buffer) abort
return 'pipenv'
endif
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pycodestyle_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
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$'
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run pycodestyle'
\ : ''

View File

@ -5,6 +5,7 @@ call ale#Set('python_pydocstyle_executable', 'pydocstyle')
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)
function! ale_linters#python#pydocstyle#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pydocstyle_auto_pipenv'))
@ -12,12 +13,17 @@ function! ale_linters#python#pydocstyle#GetExecutable(buffer) abort
return 'pipenv'
endif
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pydocstyle_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
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$'
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run pydocstyle'
\ : ''

View File

@ -4,6 +4,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)
function! ale_linters#python#pyflakes#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyflakes_auto_pipenv'))
@ -11,13 +12,18 @@ function! ale_linters#python#pyflakes#GetExecutable(buffer) abort
return 'pipenv'
endif
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyflakes_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
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$'
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run pyflakes'
\ : ''

View File

@ -5,6 +5,7 @@ call ale#Set('python_pylama_executable', 'pylama')
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_change_directory', 1)
function! ale_linters#python#pylama#GetExecutable(buffer) abort
@ -13,6 +14,11 @@ function! ale_linters#python#pylama#GetExecutable(buffer) abort
return 'pipenv'
endif
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pylama_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
endif
return ale#python#FindExecutable(a:buffer, 'python_pylama', ['pylama'])
endfunction
@ -31,7 +37,7 @@ endfunction
function! ale_linters#python#pylama#GetCommand(buffer) abort
let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer)
let l:exec_args = l:executable =~? 'pipenv$'
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run pylama'
\ : ''

View File

@ -6,6 +6,7 @@ call ale#Set('python_pylint_options', '')
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_use_msg_id', 0)
function! ale_linters#python#pylint#GetExecutable(buffer) abort
@ -14,6 +15,11 @@ function! ale_linters#python#pylint#GetExecutable(buffer) abort
return 'pipenv'
endif
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pylint_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
endif
return ale#python#FindExecutable(a:buffer, 'python_pylint', ['pylint'])
endfunction
@ -32,7 +38,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$'
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run pylint'
\ : ''

View File

@ -5,6 +5,7 @@ call ale#Set('python_pylsp_executable', 'pylsp')
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_config', {})
function! ale_linters#python#pylsp#GetExecutable(buffer) abort
@ -13,13 +14,18 @@ function! ale_linters#python#pylsp#GetExecutable(buffer) abort
return 'pipenv'
endif
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pylsp_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
endif
return ale#python#FindExecutable(a:buffer, 'python_pylsp', ['pylsp'])
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$'
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run pylsp'
\ : ''

View File

@ -4,6 +4,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)
function! ale_linters#python#pyre#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyre_auto_pipenv'))
@ -11,13 +12,18 @@ function! ale_linters#python#pyre#GetExecutable(buffer) abort
return 'pipenv'
endif
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyre_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
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$'
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run pyre persistent'
\ : ' persistent'

View File

@ -29,7 +29,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$'
let l:exec_args = l:executable =~? 'pipenv\|poetry$'
\ ? ' run vulture'
\ : ''
let l:lint_dest = ale#Var(a:buffer, 'python_vulture_change_directory')

View File

@ -5,6 +5,7 @@ call ale#Set('python_black_executable', 'black')
call ale#Set('python_black_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_black_options', '')
call ale#Set('python_black_auto_pipenv', 0)
call ale#Set('python_black_auto_poetry', 0)
call ale#Set('python_black_change_directory', 1)
function! ale#fixers#black#GetExecutable(buffer) abort
@ -13,6 +14,11 @@ function! ale#fixers#black#GetExecutable(buffer) abort
return 'pipenv'
endif
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_black_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
endif
return ale#python#FindExecutable(a:buffer, 'python_black', ['black'])
endfunction
@ -20,7 +26,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$'
if l:executable =~? 'pipenv\|poetry$'
call extend(l:cmd, ['run', 'black'])
endif

View File

@ -2,6 +2,7 @@
" Description: Functions for integrating with Python linters.
call ale#Set('python_auto_pipenv', '0')
call ale#Set('python_auto_poetry', '0')
let s:sep = has('win32') ? '\' : '/'
" bin is used for Unix virtualenv directories, and Scripts is for Windows.
@ -158,3 +159,8 @@ endfunction
function! ale#python#PipenvPresent(buffer) abort
return findfile('Pipfile.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# ''
endfunction
" Detects whether a poetry environment is present.
function! ale#python#PoetryPresent(buffer) abort
return findfile('poetry.lock', expand('#' . a:buffer . ':p:h') . ';') isnot# ''
endfunction

View File

@ -10,6 +10,14 @@ g:ale_python_auto_pipenv *g:ale_python_auto_pipenv*
Detect whether the file is inside a pipenv, and set the executable to `pipenv`
if true. This is overridden by a manually-set executable.
g:ale_python_auto_poetry *g:ale_python_auto_poetry*
*b:ale_python_auto_poetry*
Type: |Number|
Default: `0`
Detect whether the file is inside a poetry, and set the executable to `poetry`
if true. This is overridden by a manually-set executable.
===============================================================================
ALE Python Project Root Behavior *ale-python-root*
@ -136,6 +144,7 @@ g:ale_python_bandit_executable *g:ale_python_bandit_executable*
See |ale-integrations-local-executables|
Set this to `'pipenv'` to invoke `'pipenv` `run` `bandit'`.
Set this to `'poetry'` to invoke `'poetry` `run` `bandit'`.
g:ale_python_bandit_options *g:ale_python_bandit_options*
@ -175,6 +184,15 @@ g:ale_python_bandit_auto_pipenv *g:ale_python_bandit_auto_pipenv*
if true. This is overridden by a manually-set executable.
g:ale_python_bandit_auto_poetry *g:ale_python_bandit_auto_poetry*
*b:ale_python_bandit_auto_poetry*
Type: |Number|
Default: `0`
Detect whether the file is inside a poetry, and set the executable to `poetry`
if true. This is overridden by a manually-set executable.
===============================================================================
black *ale-python-black*
@ -210,6 +228,14 @@ g:ale_python_black_auto_pipenv *g:ale_python_black_auto_pipenv*
Detect whether the file is inside a pipenv, and set the executable to `pipenv`
if true. This is overridden by a manually-set executable.
g:ale_python_black_auto_poetry *g:ale_python_black_auto_poetry*
*b:ale_python_black_auto_poetry*
Type: |Number|
Default: `0`
Detect whether the file is inside a poetry, and set the executable to `poetry`
if true. This is overridden by a manually-set executable.
g:ale_python_black_change_directory *g:ale_python_black_change_directory*
*b:ale_python_black_change_directory*
Type: |Number|
@ -242,7 +268,8 @@ g:ale_python_flake8_executable *g:ale_python_flake8_executable*
Default: `'flake8'`
This variable can be changed to modify the executable used for flake8. Set
this to `'pipenv'` to invoke `'pipenv` `run` `flake8'`.
this to `'pipenv'` to invoke `'pipenv` `run` `flake8'`. Set this to
`'poetry'` to invoke `'poetry` `run` `flake8'`.
g:ale_python_flake8_options *g:ale_python_flake8_options*
@ -284,6 +311,15 @@ g:ale_python_flake8_auto_pipenv *g:ale_python_flake8_auto_pipenv*
if true. This is overridden by a manually-set executable.
g:ale_python_flake8_auto_poetry *g:ale_python_flake8_auto_poetry*
*b:ale_python_flake8_auto_poetry*
Type: |Number|
Default: `0`
Detect whether the file is inside a poetry, and set the executable to `poetry`
if true. This is overridden by a manually-set executable.
===============================================================================
isort *ale-python-isort*
@ -339,6 +375,15 @@ g:ale_python_mypy_auto_pipenv *g:ale_python_mypy_auto_pipenv*
if true. This is overridden by a manually-set executable.
g:ale_python_mypy_auto_poetry *g:ale_python_mypy_auto_poetry*
*b:ale_python_mypy_auto_poetry*
Type: |Number|
Default: `0`
Detect whether the file is inside a poetry, and set the executable to `poetry`
if true. This is overridden by a manually-set executable.
g:ale_python_mypy_executable *g:ale_python_mypy_executable*
*b:ale_python_mypy_executable*
Type: |String|
@ -347,6 +392,7 @@ g:ale_python_mypy_executable *g:ale_python_mypy_executable*
See |ale-integrations-local-executables|
Set this to `'pipenv'` to invoke `'pipenv` `run` `mypy'`.
Set this to `'poetry'` to invoke `'poetry` `run` `mypy'`.
g:ale_python_mypy_ignore_invalid_syntax
@ -397,6 +443,7 @@ g:ale_python_prospector_executable *g:ale_python_prospector_executable*
See |ale-integrations-local-executables|
Set this to `'pipenv'` to invoke `'pipenv` `run` `prospector'`.
Set this to `'poetry'` to invoke `'poetry` `run` `prospector'`.
g:ale_python_prospector_options *g:ale_python_prospector_options*
@ -437,6 +484,15 @@ g:ale_python_prospector_auto_pipenv *g:ale_python_prospector_auto_pipenv*
if true. This is overridden by a manually-set executable.
g:ale_python_prospector_auto_poetry *g:ale_python_prospector_auto_poetry*
*b:ale_python_prospector_auto_poetry*
Type: |Number|
Default: `0`
Detect whether the file is inside a poetry, and set the executable to `poetry`
if true. This is overridden by a manually-set executable.
===============================================================================
pycodestyle *ale-python-pycodestyle*
@ -449,6 +505,7 @@ g:ale_python_pycodestyle_executable *g:ale_python_pycodestyle_executable*
See |ale-integrations-local-executables|
Set this to `'pipenv'` to invoke `'pipenv` `run` `pycodestyle'`.
Set this to `'poetry'` to invoke `'poetry` `run` `pycodestyle'`.
g:ale_python_pycodestyle_options *g:ale_python_pycodestyle_options*
@ -477,6 +534,15 @@ g:ale_python_pycodestyle_auto_pipenv *g:ale_python_pycodestyle_auto_pipenv*
if true. This is overridden by a manually-set executable.
g:ale_python_pycodestyle_auto_poetry *g:ale_python_pycodestyle_auto_poetry*
*b:ale_python_pycodestyle_auto_poetry*
Type: |Number|
Default: `0`
Detect whether the file is inside a poetry, and set the executable to `poetry`
if true. This is overridden by a manually-set executable.
===============================================================================
pydocstyle *ale-python-pydocstyle*
@ -489,6 +555,7 @@ g:ale_python_pydocstyle_executable *g:ale_python_pydocstyle_executable*
See |ale-integrations-local-executables|
Set this to `'pipenv'` to invoke `'pipenv` `run` `pydocstyle'`.
Set this to `'poetry'` to invoke `'poetry` `run` `pydocstyle'`.
g:ale_python_pydocstyle_options *g:ale_python_pydocstyle_options*
@ -517,6 +584,15 @@ g:ale_python_pydocstyle_auto_pipenv *g:ale_python_pydocstyle_auto_pipenv*
if true. This is overridden by a manually-set executable.
g:ale_python_pydocstyle_auto_poetry *g:ale_python_pydocstyle_auto_poetry*
*b:ale_python_pydocstyle_auto_poetry*
Type: |Number|
Default: `0`
Detect whether the file is inside a poetry, and set the executable to `poetry`
if true. This is overridden by a manually-set executable.
===============================================================================
pyflakes *ale-python-pyflakes*
@ -529,6 +605,7 @@ g:ale_python_pyflakes_executable *g:ale_python_pyflakes_executable*
See |ale-integrations-local-executables|
Set this to `'pipenv'` to invoke `'pipenv` `run` `pyflakes'`.
Set this to `'poetry'` to invoke `'poetry` `run` `pyflakes'`.
g:ale_python_pyflakes_auto_pipenv *g:ale_python_pyflakes_auto_pipenv*
@ -540,6 +617,15 @@ g:ale_python_pyflakes_auto_pipenv *g:ale_python_pyflakes_auto_pipenv*
if true. This is overridden by a manually-set executable.
g:ale_python_pyflakes_auto_poetry *g:ale_python_pyflakes_auto_poetry*
*b:ale_python_pyflakes_auto_poetry*
Type: |Number|
Default: `0`
Detect whether the file is inside a poetry, and set the executable to `poetry`
if true. This is overridden by a manually-set executable.
===============================================================================
pylama *ale-python-pylama*
@ -561,7 +647,8 @@ g:ale_python_pylama_executable *g:ale_python_pylama_executable*
Default: `'pylama'`
This variable can be changed to modify the executable used for pylama. Set
this to `'pipenv'` to invoke `'pipenv` `run` `pylama'`.
this to `'pipenv'` to invoke `'pipenv` `run` `pylama'`. Set this to
`'poetry'` to invoke `'poetry` `run` `pylama'`.
g:ale_python_pylama_options *g:ale_python_pylama_options*
@ -594,6 +681,15 @@ g:ale_python_pylama_auto_pipenv *g:ale_python_pylama_auto_pipenv*
if true. This is overridden by a manually-set executable.
g:ale_python_pylama_auto_poetry *g:ale_python_pylama_auto_poetry*
*b:ale_python_pylama_auto_poetry*
Type: |Number|
Default: `0`
Detect whether the file is inside a poetry, and set the executable to `poetry`
if true. This is overridden by a manually-set executable.
===============================================================================
pylint *ale-python-pylint*
@ -618,6 +714,7 @@ g:ale_python_pylint_executable *g:ale_python_pylint_executable*
See |ale-integrations-local-executables|
Set this to `'pipenv'` to invoke `'pipenv` `run` `pylint'`.
Set this to `'poetry'` to invoke `'poetry` `run` `pylint'`.
g:ale_python_pylint_options *g:ale_python_pylint_options*
@ -657,6 +754,15 @@ g:ale_python_pylint_auto_pipenv *g:ale_python_pylint_auto_pipenv*
if true. This is overridden by a manually-set executable.
g:ale_python_pylint_auto_poetry *g:ale_python_pylint_auto_poetry*
*b:ale_python_pylint_auto_poetry*
Type: |Number|
Default: `0`
Detect whether the file is inside a poetry, and set the executable to `poetry`
if true. This is overridden by a manually-set executable.
g:ale_python_pylint_use_msg_id *g:ale_python_pylint_use_msg_id*
*b:ale_python_pylint_use_msg_id*
Type: |Number|
@ -680,6 +786,7 @@ g:ale_python_pylsp_executable *g:ale_python_pylsp_executable
See |ale-integrations-local-executables|
Set this to `'pipenv'` to invoke `'pipenv` `run` `pylsp'`.
Set this to `'poetry'` to invoke `'poetry` `run` `pyls'`.
g:ale_python_pylsp_use_global *g:ale_python_pylsp_use_global*
@ -699,6 +806,15 @@ g:ale_python_pylsp_auto_pipenv *g:ale_python_pylsp_auto_pipenv
if true. This is overridden by a manually-set executable.
g:ale_python_pylsp_auto_poetry *g:ale_python_pylsp_auto_poetry*
*b:ale_python_pylsp_auto_poetry*
Type: |Number|
Default: `0`
Detect whether the file is inside a poetry, and set the executable to `poetry`
if true. This is overridden by a manually-set executable.
g:ale_python_pylsp_config *g:ale_python_pylsp_config*
*b:ale_python_pylsp_config*
Type: |Dictionary|
@ -750,6 +866,7 @@ g:ale_python_pyre_executable *g:ale_python_pyre_executable*
See |ale-integrations-local-executables|
Set this to `'pipenv'` to invoke `'pipenv` `run` `pyre'`.
Set this to `'poetry'` to invoke `'poetry` `run` `pyre'`.
g:ale_python_pyre_use_global *g:ale_python_pyre_use_global*
@ -769,6 +886,15 @@ g:ale_python_pyre_auto_pipenv *g:ale_python_pyre_auto_pipenv*
if true. This is overridden by a manually-set executable.
g:ale_python_pyre_auto_poetry *g:ale_python_pyre_auto_poetry*
*b:ale_python_pyre_auto_poetry*
Type: |Number|
Default: `0`
Detect whether the file is inside a poetry, and set the executable to `poetry`
if true. This is overridden by a manually-set executable.
===============================================================================
pyright *ale-python-pyright*

View File

@ -172,6 +172,9 @@ let g:ale_completion_enabled = get(g:, 'ale_completion_enabled', 0)
" Enable automatic detection of pipenv for Python linters.
let g:ale_python_auto_pipenv = get(g:, 'ale_python_auto_pipenv', 0)
" Enable automatic detection of poetry for Python linters.
let g:ale_python_auto_poetry = get(g:, 'ale_python_auto_poetry', 0)
" This variable can be overridden to set the GO111MODULE environment variable.
let g:ale_go_go111module = get(g:, 'ale_go_go111module', '')

View File

@ -55,3 +55,13 @@ Execute(Pipenv is detected when python_black_auto_pipenv is set):
AssertEqual
\ {'command': ale#Escape('pipenv') . ' run black -'},
\ ale#fixers#black#Fix(bufnr(''))
Execute(Poetry is detected when python_black_auto_poetry is set):
let g:ale_python_black_auto_poetry = 1
let g:ale_python_black_change_directory = 0
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
AssertEqual
\ {'command': ale#Escape('poetry') . ' run black -'},
\ ale#fixers#black#Fix(bufnr(''))

View File

@ -48,6 +48,25 @@ Execute(Pipenv is detected when python_bandit_auto_pipenv is set):
\ . b:bandit_flags
\ . ' -'
Execute(Setting executable to 'poetry' appends 'run bandit'):
let g:ale_python_bandit_executable = 'path/to/poetry'
AssertLinter 'path/to/poetry',
\ ale#Escape('path/to/poetry')
\ . ' run bandit'
\ . b:bandit_flags
\ . ' -'
Execute(Poetry is detected when python_bandit_auto_poetry is set):
let g:ale_python_bandit_auto_poetry = 1
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
AssertLinter 'poetry',
\ ale#Escape('poetry')
\ . ' run bandit'
\ . b:bandit_flags
\ . ' -'
Execute(The bandit command callback should add .bandit by default):
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_bandit/namespace/foo/bar.py')

View File

@ -199,3 +199,19 @@ Execute(Pipenv is detected when python_flake8_auto_pipenv is set):
AssertLinterCwd ale#python#FindProjectRootIni(bufnr(''))
AssertLinter 'pipenv',
\ ale#Escape('pipenv') . ' run flake8 --format=default --stdin-display-name %s -'
Execute(Setting executable to 'poetry' should append 'run flake8'):
let g:ale_python_flake8_executable = 'path/to/poetry'
" FIXME: poetry should check the version with flake8.
GivenCommandOutput []
AssertLinter 'path/to/poetry',
\ ale#Escape('path/to/poetry') . ' run flake8 --format=default -'
Execute(poetry is detected when python_flake8_auto_poetry is set):
let g:ale_python_flake8_auto_poetry = 1
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
AssertLinterCwd ale#python#FindProjectRootIni(bufnr(''))
AssertLinter 'poetry',
\ ale#Escape('poetry') . ' run flake8 --format=default --stdin-display-name %s -'

View File

@ -88,3 +88,19 @@ Execute(Pipenv is detected when python_mypy_auto_pipenv is set):
AssertLinterCwd expand('#' . bufnr('') . ':p:h')
AssertLinter 'pipenv',
\ ale#Escape('pipenv') . ' run mypy --show-column-numbers --shadow-file %s %t %s'
Execute(Setting executable to 'poetry' appends 'run mypy'):
let g:ale_python_mypy_executable = 'path/to/poetry'
AssertLinterCwd expand('#' . bufnr('') . ':p:h')
AssertLinter 'path/to/poetry',
\ ale#Escape('path/to/poetry') . ' run mypy'
\ . ' --show-column-numbers --shadow-file %s %t %s'
Execute(Poetry is detected when python_mypy_auto_poetry is set):
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
let g:ale_python_mypy_auto_poetry = 1
AssertLinterCwd expand('#' . bufnr('') . ':p:h')
AssertLinter 'poetry',
\ ale#Escape('poetry') . ' run mypy --show-column-numbers --shadow-file %s %t %s'

View File

@ -18,3 +18,18 @@ Execute(Pipenv is detected when python_prospector_auto_pipenv is set):
AssertLinter 'pipenv',
\ ale#Escape('pipenv') . ' run prospector'
\ . ' --messages-only --absolute-paths --zero-exit --output-format json %s'
Execute(Setting executable to 'poetry' appends 'run prospector'):
let g:ale_python_prospector_executable = 'path/to/poetry'
AssertLinter 'path/to/poetry',
\ ale#Escape('path/to/poetry') . ' run prospector'
\ . ' --messages-only --absolute-paths --zero-exit --output-format json %s'
Execute(Poetry is detected when python_prospector_auto_poetry is set):
let g:ale_python_prospector_auto_poetry = 1
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
AssertLinter 'poetry',
\ ale#Escape('poetry') . ' run prospector'
\ . ' --messages-only --absolute-paths --zero-exit --output-format json %s'

View File

@ -31,3 +31,16 @@ Execute(Pipenv is detected when python_pycodestyle_auto_pipenv is set):
AssertLinter 'pipenv',
\ ale#Escape('pipenv') . ' run pycodestyle -'
Execute(Setting executable to 'poetry' appends 'run pycodestyle'):
let g:ale_python_pycodestyle_executable = 'path/to/poetry'
AssertLinter 'path/to/poetry',
\ ale#Escape('path/to/poetry') . ' run pycodestyle -'
Execute(Poetry is detected when python_pycodestyle_auto_poetry is set):
let g:ale_python_pycodestyle_auto_poetry = 1
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
AssertLinter 'poetry',
\ ale#Escape('poetry') . ' run pycodestyle -'

View File

@ -31,3 +31,15 @@ Execute(Pipenv is detected when python_pydocstyle_auto_pipenv is set):
call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
AssertLinter 'pipenv', ale#Escape('pipenv') . ' run pydocstyle %s:t'
Execute(Setting executable to 'poetry' appends 'run pydocstyle'):
let g:ale_python_pydocstyle_executable = 'path/to/poetry'
AssertLinter 'path/to/poetry',
\ ale#Escape('path/to/poetry') . ' run pydocstyle %s:t'
Execute(Poetry is detected when python_pydocstyle_auto_poetry is set):
let g:ale_python_pydocstyle_auto_poetry = 1
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
AssertLinter 'poetry', ale#Escape('poetry') . ' run pydocstyle %s:t'

View File

@ -44,3 +44,16 @@ Execute(Pipenv is detected when python_pyflakes_auto_pipenv is set):
AssertLinter 'pipenv',
\ ale#Escape('pipenv') . ' run pyflakes %t'
Execute(Setting executable to 'poetry' appends 'run pyflakes'):
let g:ale_python_pyflakes_executable = 'path/to/poetry'
AssertLinter 'path/to/poetry',
\ ale#Escape('path/to/poetry') . ' run pyflakes %t',
Execute(Poetry is detected when python_pyflakes_auto_poetry is set):
let g:ale_python_pyflakes_auto_poetry = 1
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
AssertLinter 'poetry',
\ ale#Escape('poetry') . ' run pyflakes %t'

View File

@ -74,3 +74,15 @@ Execute(Pipenv is detected when python_pylama_auto_pipenv is set):
call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
AssertLinter 'pipenv', ale#Escape('pipenv') . ' run pylama' . b:command_tail
Execute(Setting executable to 'poetry' appends 'run pylama'):
let g:ale_python_pylama_executable = 'path/to/poetry'
AssertLinter 'path/to/poetry',
\ ale#Escape('path/to/poetry') . ' run pylama' . b:command_tail
Execute(poetry is detected when python_pylama_auto_poetry is set):
let g:ale_python_pylama_auto_poetry = 1
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
AssertLinter 'poetry', ale#Escape('poetry') . ' run pylama' . b:command_tail

View File

@ -79,3 +79,18 @@ Execute(Pipenv is detected when python_pylint_auto_pipenv is set):
AssertLinterCwd expand('%:p:h')
AssertLinter 'pipenv', ale#Escape('pipenv') . ' run pylint'
\ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s'
Execute(Setting executable to 'poetry' appends 'run pylint'):
let g:ale_python_pylint_executable = 'path/to/poetry'
let g:ale_python_pylint_use_global = 1
AssertLinter 'path/to/poetry', ale#Escape('path/to/poetry') . ' run pylint'
\ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s'
Execute(poetry is detected when python_pylint_auto_poetry is set):
let g:ale_python_pylint_auto_poetry = 1
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
AssertLinterCwd expand('%:p:h')
AssertLinter 'poetry', ale#Escape('poetry') . ' run pylint'
\ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s'

View File

@ -51,6 +51,18 @@ Execute(Pipenv is detected when python_pylsp_auto_pipenv is set):
AssertLinter 'pipenv',
\ ale#Escape('pipenv') . ' run pylsp'
Execute(Setting executable to 'poetry' appends 'run pylsp'):
let g:ale_python_pylsp_executable = 'path/to/poetry'
AssertLinter 'path/to/poetry', ale#Escape('path/to/poetry') . ' run pylsp'
Execute(poetry is detected when python_pylsp_auto_poetry is set):
let g:ale_python_pylsp_auto_poetry = 1
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
AssertLinter 'poetry',
\ ale#Escape('poetry') . ' run pylsp'
Execute(Should accept configuration settings):
AssertLSPConfig {}
let b:ale_python_pylsp_config = {'pylsp': {'plugins': {'preload': {'enabled': v:false}}}}

View File

@ -44,3 +44,16 @@ Execute(Pipenv is detected when python_pyre_auto_pipenv is set):
AssertLinter 'pipenv',
\ ale#Escape('pipenv') . ' run pyre persistent'
Execute(Setting executable to 'poetry' appends 'run pyre'):
let g:ale_python_pyre_executable = 'path/to/poetry'
AssertLinter 'path/to/poetry',
\ ale#Escape('path/to/poetry') . ' run pyre persistent'
Execute(Poetry is detected when python_pyre_auto_poetry is set):
let g:ale_python_pyre_auto_poetry = 1
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
AssertLinter 'poetry',
\ ale#Escape('poetry') . ' run pyre persistent'

View File

@ -56,3 +56,7 @@ Execute(Setting executable to 'pipenv' appends 'run vulture'):
let g:ale_python_vulture_executable = 'path/to/pipenv'
AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run vulture' . ' .'
Execute(Setting executable to 'poetry' appends 'run vulture'):
let g:ale_python_vulture_executable = 'path/to/poetry'
AssertLinter 'path/to/poetry', ale#Escape('path/to/poetry') . ' run vulture' . ' .'

View File

View File

@ -11,7 +11,7 @@ Execute(ale#python#PipenvPresent is true when a pipenv environment is present):
\ ale#python#PipenvPresent(bufnr('%')),
\ 1
Execute(ale#python#PipenvPresent is false true when no pipenv environment is present):
Execute(ale#python#PipenvPresent is false when no pipenv environment is present):
call ale#test#SetFilename('test-files/python/no_pipenv/whatever.py')
AssertEqual

View File

@ -0,0 +1,19 @@
Before:
call ale#test#SetDirectory('/testplugin/test')
After:
call ale#test#RestoreDirectory()
Execute(ale#python#poetryPresent is true when a poetry environment is present):
call ale#test#SetFilename('test-files/python/poetry/whatever.py')
AssertEqual
\ ale#python#PoetryPresent(bufnr('%')),
\ 1
Execute(ale#python#poetryPresent is false when no poetry environment is present):
call ale#test#SetFilename('test-files/python/no_poetry/whatever.py')
AssertEqual
\ ale#python#PoetryPresent(bufnr('%')),
\ 0