mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-16 01:07:06 +08:00
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:
@@ -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')
|
||||
|
||||
|
||||
@@ -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 -'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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 -'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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}}}}
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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' . ' .'
|
||||
|
||||
Reference in New Issue
Block a user