summaryrefslogtreecommitdiff
path: root/ale_linters/python
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters/python')
-rw-r--r--ale_linters/python/ruff.vim19
1 files changed, 11 insertions, 8 deletions
diff --git a/ale_linters/python/ruff.vim b/ale_linters/python/ruff.vim
index 617ef5b7..c4f8ad1b 100644
--- a/ale_linters/python/ruff.vim
+++ b/ale_linters/python/ruff.vim
@@ -47,22 +47,25 @@ function! ale_linters#python#ruff#GetCommand(buffer, version) abort
" NOTE: ruff version `0.0.69` supports liniting input from stdin
" NOTE: ruff version `0.1.0` deprecates `--format text`
- return ale#Escape(l:executable) . l:exec_args
+ return ale#Escape(l:executable) . l:exec_args . ' -q'
\ . ale#Pad(ale#Var(a:buffer, 'python_ruff_options'))
- \ . (ale#semver#GTE(a:version, [0, 1, 0]) ? ' --output-format text' : ' --format text')
+ \ . (ale#semver#GTE(a:version, [0, 1, 0]) ? ' --output-format json-lines' : ' --format json-lines')
\ . (ale#semver#GTE(a:version, [0, 0, 69]) ? ' --stdin-filename %s -' : ' %s')
endfunction
function! ale_linters#python#ruff#Handle(buffer, lines) abort
- "Example: path/to/file.py:10:5: E999 SyntaxError: unexpected indent
- let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.+)$'
let l:output = []
- for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ for l:line in a:lines
+ let l:item = json_decode(l:line)
call add(l:output, {
- \ 'lnum': l:match[1] + 0,
- \ 'col': l:match[2] + 0,
- \ 'text': l:match[3],
+ \ 'lnum': l:item.location.row,
+ \ 'col': l:item.location.column,
+ \ 'end_lnum': l:item.end_location.row,
+ \ 'end_col': l:item.end_location.column - 1,
+ \ 'code': l:item.code,
+ \ 'text': l:item.message,
+ \ 'type': l:item.code =~? '\vE\d+' ? 'E' : 'W',
\})
endfor