diff options
32 files changed, 414 insertions, 16 deletions
diff --git a/ale_linters/python/bandit.vim b/ale_linters/python/bandit.vim index 554f5000..9cfca7c0 100644 --- a/ale_linters/python/bandit.vim +++ b/ale_linters/python/bandit.vim @@ -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' \ : '' diff --git a/ale_linters/python/flake8.vim b/ale_linters/python/flake8.vim index 1d49d03f..9950614a 100644 --- a/ale_linters/python/flake8.vim +++ b/ale_linters/python/flake8.vim @@ -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' \ : '' diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim index 48697421..9d469a1a 100644 --- a/ale_linters/python/mypy.vim +++ b/ale_linters/python/mypy.vim @@ -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' \ : '' diff --git a/ale_linters/python/prospector.vim b/ale_linters/python/prospector.vim index ee47012f..3623bda0 100644 --- a/ale_linters/python/prospector.vim +++ b/ale_linters/python/prospector.vim @@ -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' \ : '' diff --git a/ale_linters/python/pycodestyle.vim b/ale_linters/python/pycodestyle.vim index fb521bc1..3fb94d69 100644 --- a/ale_linters/python/pycodestyle.vim +++ b/ale_linters/python/pycodestyle.vim @@ -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' \ : '' diff --git a/ale_linters/python/pydocstyle.vim b/ale_linters/python/pydocstyle.vim index abf95fa1..aa0e8b20 100644 --- a/ale_linters/python/pydocstyle.vim +++ b/ale_linters/python/pydocstyle.vim @@ -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' \ : '' diff --git a/ale_linters/python/pyflakes.vim b/ale_linters/python/pyflakes.vim index b5127022..2567c533 100644 --- a/ale_linters/python/pyflakes.vim +++ b/ale_linters/python/pyflakes.vim @@ -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' \ : '' diff --git a/ale_linters/python/pylama.vim b/ale_linters/python/pylama.vim index bad69667..73b59b07 100644 --- a/ale_linters/python/pylama.vim +++ b/ale_linters/python/pylama.vim @@ -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' \ : '' diff --git a/ale_linters/python/pylint.vim b/ale_linters/python/pylint.vim index f086a865..2ce5376f 100644 --- a/ale_linters/python/pylint.vim +++ b/ale_linters/python/pylint.vim @@ -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' \ : '' diff --git a/ale_linters/python/pylsp.vim b/ale_linters/python/pylsp.vim index 4c6ac16d..537d1e74 100644 --- a/ale_linters/python/pylsp.vim +++ b/ale_linters/python/pylsp.vim @@ -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' \ : '' diff --git a/ale_linters/python/pyre.vim b/ale_linters/python/pyre.vim index 4edd80f7..d9b46763 100644 --- a/ale_linters/python/pyre.vim +++ b/ale_linters/python/pyre.vim @@ -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' diff --git a/ale_linters/python/vulture.vim b/ale_linters/python/vulture.vim index 84ffd49a..a7ba1860 100644 --- a/ale_linters/python/vulture.vim +++ b/ale_linters/python/vulture.vim @@ -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') diff --git a/autoload/ale/fixers/black.vim b/autoload/ale/fixers/black.vim index 142cd983..4a88c5cd 100644 --- a/autoload/ale/fixers/black.vim +++ b/autoload/ale/fixers/black.vim @@ -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 diff --git a/autoload/ale/python.vim b/autoload/ale/python.vim index 40433d17..ee856a27 100644 --- a/autoload/ale/python.vim +++ b/autoload/ale/python.vim @@ -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 diff --git a/doc/ale-python.txt b/doc/ale-python.txt index 7d390d54..7f746147 100644 --- a/doc/ale-python.txt +++ b/doc/ale-python.txt @@ -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* diff --git a/plugin/ale.vim b/plugin/ale.vim index 7c79f261..0268bc99 100644 --- a/plugin/ale.vim +++ b/plugin/ale.vim @@ -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', '') diff --git a/test/fixers/test_black_fixer_callback.vader b/test/fixers/test_black_fixer_callback.vader index a69eafd9..bb76a1fe 100644 --- a/test/fixers/test_black_fixer_callback.vader +++ b/test/fixers/test_black_fixer_callback.vader @@ -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('')) diff --git a/test/linter/test_bandit.vader b/test/linter/test_bandit.vader index 3d3a60a3..e9488c00 100644 --- a/test/linter/test_bandit.vader +++ b/test/linter/test_bandit.vader @@ -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') diff --git a/test/linter/test_flake8.vader b/test/linter/test_flake8.vader index 81efe497..0b87c27b 100644 --- a/test/linter/test_flake8.vader +++ b/test/linter/test_flake8.vader @@ -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 -' diff --git a/test/linter/test_mypy.vader b/test/linter/test_mypy.vader index 8c1e5e9c..bac59d92 100644 --- a/test/linter/test_mypy.vader +++ b/test/linter/test_mypy.vader @@ -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' diff --git a/test/linter/test_prospector.vader b/test/linter/test_prospector.vader index d6f84308..82e1596d 100644 --- a/test/linter/test_prospector.vader +++ b/test/linter/test_prospector.vader @@ -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' diff --git a/test/linter/test_pycodestyle.vader b/test/linter/test_pycodestyle.vader index 9260913c..fac53d9f 100644 --- a/test/linter/test_pycodestyle.vader +++ b/test/linter/test_pycodestyle.vader @@ -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 -' diff --git a/test/linter/test_pydocstyle.vader b/test/linter/test_pydocstyle.vader index b24cb0d9..24d669c6 100644 --- a/test/linter/test_pydocstyle.vader +++ b/test/linter/test_pydocstyle.vader @@ -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' diff --git a/test/linter/test_pyflakes.vader b/test/linter/test_pyflakes.vader index bbb7b74c..bd442098 100644 --- a/test/linter/test_pyflakes.vader +++ b/test/linter/test_pyflakes.vader @@ -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' diff --git a/test/linter/test_pylama.vader b/test/linter/test_pylama.vader index 29fa971b..3c6a6efa 100644 --- a/test/linter/test_pylama.vader +++ b/test/linter/test_pylama.vader @@ -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 diff --git a/test/linter/test_pylint.vader b/test/linter/test_pylint.vader index e581915f..d15161e6 100644 --- a/test/linter/test_pylint.vader +++ b/test/linter/test_pylint.vader @@ -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' diff --git a/test/linter/test_pylsp.vader b/test/linter/test_pylsp.vader index 9d7d0775..acee2c3f 100644 --- a/test/linter/test_pylsp.vader +++ b/test/linter/test_pylsp.vader @@ -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}}}} diff --git a/test/linter/test_pyre.vader b/test/linter/test_pyre.vader index d3e5fe9d..335e31f2 100644 --- a/test/linter/test_pyre.vader +++ b/test/linter/test_pyre.vader @@ -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' diff --git a/test/linter/test_vulture.vader b/test/linter/test_vulture.vader index 74709c9e..78655bd7 100644 --- a/test/linter/test_vulture.vader +++ b/test/linter/test_vulture.vader @@ -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' . ' .' diff --git a/test/test-files/python/poetry/poetry.lock b/test/test-files/python/poetry/poetry.lock new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/test-files/python/poetry/poetry.lock diff --git a/test/test_python_pipenv.vader b/test/test_python_pipenv.vader index 8b1e9ab0..041e2874 100644 --- a/test/test_python_pipenv.vader +++ b/test/test_python_pipenv.vader @@ -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 diff --git a/test/test_python_poetry.vader b/test/test_python_poetry.vader new file mode 100644 index 00000000..8197b786 --- /dev/null +++ b/test/test_python_poetry.vader @@ -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 |