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: Author: Jon Parise <jon@indelible.org>
3 call ale#Set('python_unimport_executable', 'unimport')
4 call ale#Set('python_unimport_options', '')
5 call ale#Set('python_unimport_use_global', get(g:, 'ale_use_global_executables', 0))
6 call ale#Set('python_unimport_auto_pipenv', 0)
7 call ale#Set('python_unimport_auto_poetry', 0)
8 call ale#Set('python_unimport_auto_uv', 0)
10 function! ale_linters#python#unimport#GetExecutable(buffer) abort
11 if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_unimport_auto_pipenv'))
12 \ && ale#python#PipenvPresent(a:buffer)
16 if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_unimport_auto_poetry'))
17 \ && ale#python#PoetryPresent(a:buffer)
21 if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_unimport_auto_uv'))
22 \ && ale#python#UvPresent(a:buffer)
26 return ale#python#FindExecutable(a:buffer, 'python_unimport', ['unimport'])
29 function! ale_linters#python#unimport#GetCommand(buffer) abort
30 let l:executable = ale_linters#python#unimport#GetExecutable(a:buffer)
31 let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
35 return '%e' . l:exec_args
36 \ . ale#Pad(ale#Var(a:buffer, 'python_unimport_options'))
42 function! ale_linters#python#unimport#GetCwd(buffer) abort
43 let l:project_root = ale#python#FindProjectRoot(a:buffer)
45 return !empty(l:project_root)
47 \ : expand('#' . a:buffer . ':p:h')
51 function! ale_linters#python#unimport#Handle(buffer, lines) abort
52 let l:output = ale#python#HandleTraceback(a:lines, 10)
60 " urllib.parse at path/to/file.py:9
61 let l:pattern = '\v(.+) at [^:]+:(\d+)$'
63 for l:match in ale#util#GetMatches(a:lines, l:pattern)
65 \ 'lnum': l:match[2] + 0,
67 \ 'text': 'unused: ' . l:match[1],
75 call ale#linter#Define('python', {
77 \ 'executable': function('ale_linters#python#unimport#GetExecutable'),
78 \ 'cwd': function('ale_linters#python#unimport#GetCwd'),
79 \ 'command': function('ale_linters#python#unimport#GetCommand'),
80 \ 'callback': 'ale_linters#python#unimport#Handle',