mirror of
https://github.com/dense-analysis/ale
synced 2025-01-03 12:32:05 +00:00
Allow syntax errors for mypy to be ignored
This commit is contained in:
parent
f1747901cc
commit
adba2bd919
@ -1,10 +1,10 @@
|
|||||||
" Author: Keith Smiley <k@keith.so>, w0rp <devw0rp@gmail.com>
|
" Author: Keith Smiley <k@keith.so>, w0rp <devw0rp@gmail.com>
|
||||||
" Description: mypy support for optional python typechecking
|
" Description: mypy support for optional python typechecking
|
||||||
|
|
||||||
let g:ale_python_mypy_executable =
|
call ale#Set('python_mypy_executable', 'mypy')
|
||||||
\ get(g:, 'ale_python_mypy_executable', 'mypy')
|
call ale#Set('python_mypy_ignore_invalid_syntax', 0)
|
||||||
let g:ale_python_mypy_options = get(g:, 'ale_python_mypy_options', '')
|
call ale#Set('python_mypy_options', '')
|
||||||
let g:ale_python_mypy_use_global = get(g:, 'ale_python_mypy_use_global', 0)
|
call ale#Set('python_mypy_use_global', 0)
|
||||||
|
|
||||||
function! ale_linters#python#mypy#GetExecutable(buffer) abort
|
function! ale_linters#python#mypy#GetExecutable(buffer) abort
|
||||||
return ale#python#FindExecutable(a:buffer, 'python_mypy', ['mypy'])
|
return ale#python#FindExecutable(a:buffer, 'python_mypy', ['mypy'])
|
||||||
@ -45,6 +45,12 @@ function! ale_linters#python#mypy#Handle(buffer, lines) abort
|
|||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
|
" Skip invalid syntax errors if the option is on.
|
||||||
|
if l:match[5] is# 'invalid syntax'
|
||||||
|
\&& ale#Var(a:buffer, 'python_mypy_ignore_invalid_syntax')
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
|
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
|
||||||
\ 'lnum': l:match[2] + 0,
|
\ 'lnum': l:match[2] + 0,
|
||||||
|
@ -104,6 +104,16 @@ g:ale_python_mypy_executable *g:ale_python_mypy_executable*
|
|||||||
|
|
||||||
See |ale-integrations-local-executables|
|
See |ale-integrations-local-executables|
|
||||||
|
|
||||||
|
g:ale_python_mypy_ignore_invalid_syntax
|
||||||
|
*g:ale_python_mypy_ignore_invalid_syntax*
|
||||||
|
*b:ale_python_mypy_ignore_invalid_syntax*
|
||||||
|
Type: |Number|
|
||||||
|
Default: `0`
|
||||||
|
|
||||||
|
When set to `1`, syntax error messages for mypy will be ignored. This option
|
||||||
|
can be used when running other Python linters which check for syntax errors,
|
||||||
|
as mypy can take a while to finish executing.
|
||||||
|
|
||||||
|
|
||||||
g:ale_python_mypy_options *g:ale_python_mypy_options*
|
g:ale_python_mypy_options *g:ale_python_mypy_options*
|
||||||
*b:ale_python_mypy_options*
|
*b:ale_python_mypy_options*
|
||||||
@ -125,16 +135,16 @@ g:ale_python_mypy_use_global *g:ale_python_mypy_use_global*
|
|||||||
===============================================================================
|
===============================================================================
|
||||||
prospector *ale-python-prospector*
|
prospector *ale-python-prospector*
|
||||||
|
|
||||||
g:ale_python_prospector_executable *g:ale_python_prospector_executable*
|
g:ale_python_prospector_executable *g:ale_python_prospector_executable*
|
||||||
*b:ale_python_prospector_executable*
|
*b:ale_python_prospector_executable*
|
||||||
Type: |String|
|
Type: |String|
|
||||||
Default: `'prospector'`
|
Default: `'prospector'`
|
||||||
|
|
||||||
See |ale-integrations-local-executables|
|
See |ale-integrations-local-executables|
|
||||||
|
|
||||||
|
|
||||||
g:ale_python_prospector_options *g:ale_python_prospector_options*
|
g:ale_python_prospector_options *g:ale_python_prospector_options*
|
||||||
*b:ale_python_prospector_options*
|
*b:ale_python_prospector_options*
|
||||||
Type: |String|
|
Type: |String|
|
||||||
Default: `''`
|
Default: `''`
|
||||||
|
|
||||||
@ -154,8 +164,8 @@ g:ale_python_prospector_options *g:ale_python_prospector_option
|
|||||||
`python3 -m pip install --user prospector`).
|
`python3 -m pip install --user prospector`).
|
||||||
|
|
||||||
|
|
||||||
g:ale_python_prospector_use_global *g:ale_python_prospector_use_global*
|
g:ale_python_prospector_use_global *g:ale_python_prospector_use_global*
|
||||||
*b:ale_python_prospector_use_global*
|
*b:ale_python_prospector_use_global*
|
||||||
Type: |Number|
|
Type: |Number|
|
||||||
Default: `0`
|
Default: `0`
|
||||||
|
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
Before:
|
Before:
|
||||||
|
Save g:ale_python_mypy_ignore_invalid_syntax
|
||||||
|
|
||||||
|
unlet! g:ale_python_mypy_ignore_invalid_syntax
|
||||||
|
|
||||||
runtime ale_linters/python/mypy.vim
|
runtime ale_linters/python/mypy.vim
|
||||||
|
|
||||||
call ale#test#SetDirectory('/testplugin/test/handler')
|
call ale#test#SetDirectory('/testplugin/test/handler')
|
||||||
|
|
||||||
After:
|
After:
|
||||||
|
Restore
|
||||||
|
|
||||||
call ale#test#RestoreDirectory()
|
call ale#test#RestoreDirectory()
|
||||||
call ale#linter#Reset()
|
call ale#linter#Reset()
|
||||||
|
|
||||||
@ -80,3 +86,27 @@ Execute(The mypy handler should handle Windows names with spaces):
|
|||||||
\ ale_linters#python#mypy#Handle(bufnr(''), [
|
\ ale_linters#python#mypy#Handle(bufnr(''), [
|
||||||
\ 'C:\something\with spaces.py:4: error: No library stub file for module ''django.db''',
|
\ 'C:\something\with spaces.py:4: error: No library stub file for module ''django.db''',
|
||||||
\ ])
|
\ ])
|
||||||
|
|
||||||
|
Execute(The mypy syntax errors shouldn't be ignored by default):
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 4,
|
||||||
|
\ 'col': 0,
|
||||||
|
\ 'filename': ale#path#Simplify(g:dir . '/foo.py'),
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ 'text': 'invalid syntax',
|
||||||
|
\ },
|
||||||
|
\ ],
|
||||||
|
\ ale_linters#python#mypy#Handle(bufnr(''), [
|
||||||
|
\ 'foo.py:4: error: invalid syntax',
|
||||||
|
\ ])
|
||||||
|
|
||||||
|
Execute(The mypy syntax errors should be ignored when the option is on):
|
||||||
|
let g:ale_python_mypy_ignore_invalid_syntax = 1
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ [],
|
||||||
|
\ ale_linters#python#mypy#Handle(bufnr(''), [
|
||||||
|
\ 'foo.py:4: error: invalid syntax',
|
||||||
|
\ ])
|
||||||
|
Loading…
Reference in New Issue
Block a user