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: Pablo Acosta <pmasdev@gmail.com>
2 " Description: pydocstyle for python files
4 call ale#Set('python_pydocstyle_executable', 'pydocstyle')
5 call ale#Set('python_pydocstyle_options', '')
6 call ale#Set('python_pydocstyle_use_global', get(g:, 'ale_use_global_executables', 0))
7 call ale#Set('python_pydocstyle_auto_pipenv', 0)
8 call ale#Set('python_pydocstyle_auto_poetry', 0)
9 call ale#Set('python_pydocstyle_auto_uv', 0)
11 function! ale_linters#python#pydocstyle#GetExecutable(buffer) abort
12 if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pydocstyle_auto_pipenv'))
13 \ && ale#python#PipenvPresent(a:buffer)
17 if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pydocstyle_auto_poetry'))
18 \ && ale#python#PoetryPresent(a:buffer)
22 if (ale#Var(a:buffer, 'python_auto_uv') || ale#Var(a:buffer, 'python_pydocstyle_auto_uv'))
23 \ && ale#python#UvPresent(a:buffer)
27 return ale#python#FindExecutable(a:buffer, 'python_pydocstyle', ['pydocstyle'])
30 function! ale_linters#python#pydocstyle#GetCommand(buffer) abort
31 let l:executable = ale_linters#python#pydocstyle#GetExecutable(a:buffer)
32 let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$'
36 return ale#Escape(l:executable) . l:exec_args
37 \ . ale#Pad(ale#Var(a:buffer, 'python_pydocstyle_options'))
41 function! ale_linters#python#pydocstyle#Handle(buffer, lines) abort
42 " Matches patterns like the following:
43 " mydir/myfile.py:33 in public function `myfunction`:
44 " DXXX: Error description
45 let l:line1_pattern = '\v^.*:\s*(\d+)\s+.*$'
46 let l:line2_pattern = '\v^.*([a-zA-Z]\d+):\s*(.*)$'
49 let l:num_lines = len(a:lines)
52 while l:index < l:num_lines
53 let l:lnum = matchlist(a:lines[l:index], l:line1_pattern)
55 if !empty(l:lnum) && (l:index + 1 < l:num_lines)
56 let l:desc = matchlist(a:lines[l:index + 1], l:line2_pattern)
60 \ 'lnum': l:lnum[1] + 0,
68 let l:index = l:index + 2
70 let l:index = l:index + 1
77 call ale#linter#Define('python', {
78 \ 'name': 'pydocstyle',
79 \ 'executable': function('ale_linters#python#pydocstyle#GetExecutable'),
81 \ 'command': function('ale_linters#python#pydocstyle#GetCommand'),
82 \ 'callback': 'ale_linters#python#pydocstyle#Handle',