All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Yauheni Kirylau <actionless.loveless@gmail.com>
2 " Description: vulture linting for python files
4 call ale#Set('python_vulture_executable', 'vulture')
5 call ale#Set('python_vulture_options', '')
6 call ale#Set('python_vulture_use_global', get(g:, 'ale_use_global_executables', 0))
7 call ale#Set('python_vulture_change_directory', 1)
8 call ale#Set('python_vulture_auto_pipenv', 0)
9 call ale#Set('python_vulture_auto_poetry', 0)
10 call ale#Set('python_vulture_auto_uv', 0)
12 " The directory to change to before running vulture
13 function! s:GetDir(buffer) abort
14 let l:project_root = ale#python#FindProjectRoot(a:buffer)
16 return !empty(l:project_root)
18 \ : expand('#' . a:buffer . ':p:h')
21 function! ale_linters#python#vulture#GetExecutable(buffer) abort
22 if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_vulture_auto_pipenv'))
23 \ && ale#python#PipenvPresent(a:buffer)
27 if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_vulture_auto_poetry'))
28 \ && ale#python#PoetryPresent(a:buffer)
32 if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_vulture_auto_uv'))
33 \ && ale#python#UvPresent(a:buffer)
37 return ale#python#FindExecutable(a:buffer, 'python_vulture', ['vulture'])
40 function! ale_linters#python#vulture#GetCwd(buffer) abort
41 if !ale#Var(a:buffer, 'python_vulture_change_directory')
45 return s:GetDir(a:buffer)
48 function! ale_linters#python#vulture#GetCommand(buffer) abort
49 let l:executable = ale_linters#python#vulture#GetExecutable(a:buffer)
50 let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
53 let l:lint_dest = ale#Var(a:buffer, 'python_vulture_change_directory')
57 return ale#Escape(l:executable) . l:exec_args
59 \ . ale#Var(a:buffer, 'python_vulture_options')
64 function! ale_linters#python#vulture#Handle(buffer, lines) abort
65 let l:output = ale#python#HandleTraceback(a:lines, 10)
71 " Matches patterns line the following:
72 let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+): (.*)$'
73 let l:dir = s:GetDir(a:buffer)
75 for l:match in ale#util#GetMatches(a:lines, l:pattern)
76 let l:abspath = ale#path#GetAbsPath(l:dir, l:match[1])
78 \ 'filename': l:abspath,
79 \ 'lnum': l:match[2] + 0,
83 call add(l:output, l:item)
90 call ale#linter#Define('python', {
92 \ 'executable': function('ale_linters#python#vulture#GetExecutable'),
93 \ 'cwd': function('ale_linters#python#vulture#GetCwd'),
94 \ 'command': function('ale_linters#python#vulture#GetCommand'),
95 \ 'callback': 'ale_linters#python#vulture#Handle',