summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorDaniel Roseman <daniel@roseman.org.uk>2021-07-25 05:39:05 +0100
committerGitHub <noreply@github.com>2021-07-25 13:39:05 +0900
commit7d8fb2ba1716a744446b811fc278ecf30d4eb771 (patch)
treecabed5301053216ab424e6f554dc7595b1948bb3 /ale_linters
parent530b38de342a21cce330a32af0c1b66671d335c2 (diff)
downloadale-7d8fb2ba1716a744446b811fc278ecf30d4eb771.zip
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>
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/python/bandit.vim10
-rw-r--r--ale_linters/python/flake8.vim8
-rw-r--r--ale_linters/python/mypy.vim8
-rw-r--r--ale_linters/python/prospector.vim8
-rw-r--r--ale_linters/python/pycodestyle.vim8
-rw-r--r--ale_linters/python/pydocstyle.vim8
-rw-r--r--ale_linters/python/pyflakes.vim8
-rw-r--r--ale_linters/python/pylama.vim8
-rw-r--r--ale_linters/python/pylint.vim8
-rw-r--r--ale_linters/python/pylsp.vim8
-rw-r--r--ale_linters/python/pyre.vim8
-rw-r--r--ale_linters/python/vulture.vim2
12 files changed, 80 insertions, 12 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')