summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2020-01-02 14:19:21 +0000
committerw0rp <devw0rp@gmail.com>2020-01-02 14:19:21 +0000
commit8c4c8dfd97b6a7d24b490f8645d7c54461c45d52 (patch)
treed442d9cec77f8e4db90d19103c399dc0d77d8043
parent0cb432cb825e80c5a6f6dc9bc9c52a38f9b45319 (diff)
downloadale-8c4c8dfd97b6a7d24b490f8645d7c54461c45d52.zip
Fix #2704 - Show mypy notes; can be disabled
-rw-r--r--ale_linters/python/mypy.vim14
-rw-r--r--doc/ale-python.txt30
-rw-r--r--test/handler/test_mypy_handler.vader27
3 files changed, 59 insertions, 12 deletions
diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim
index dc4044e6..d4778e40 100644
--- a/ale_linters/python/mypy.vim
+++ b/ale_linters/python/mypy.vim
@@ -3,6 +3,7 @@
call ale#Set('python_mypy_executable', 'mypy')
call ale#Set('python_mypy_ignore_invalid_syntax', 0)
+call ale#Set('python_mypy_show_notes', 1)
call ale#Set('python_mypy_options', '')
call ale#Set('python_mypy_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_mypy_auto_pipenv', 0)
@@ -51,7 +52,16 @@ function! ale_linters#python#mypy#Handle(buffer, lines) abort
" Lines like these should be ignored below:
"
" file.py:4: note: (Stub files are from https://github.com/python/typeshed)
- let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: (error|warning): (.+)$'
+
+ let l:types = 'error|warning'
+
+ if ale#Var(a:buffer, 'python_mypy_show_notes')
+ let l:types = 'error|warning|note'
+ endif
+
+ let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: ('
+ \ . l:types
+ \ . '): (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
@@ -65,7 +75,7 @@ function! ale_linters#python#mypy#Handle(buffer, lines) abort
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
- \ 'type': l:match[4] is# 'error' ? 'E' : 'W',
+ \ 'type': l:match[4] is# 'error' ? 'E' : (l:match[4] is# 'note' ? 'I': 'W'),
\ 'text': l:match[5],
\})
endfor
diff --git a/doc/ale-python.txt b/doc/ale-python.txt
index 9d5846d2..93f1d668 100644
--- a/doc/ale-python.txt
+++ b/doc/ale-python.txt
@@ -145,8 +145,8 @@ g:ale_python_black_use_global *g:ale_python_black_use_global*
See |ale-integrations-local-executables|
-g:ale_python_black_auto_pipenv *g:ale_python_black_auto_pipenv*
- *b:ale_python_black_auto_pipenv*
+g:ale_python_black_auto_pipenv *g:ale_python_black_auto_pipenv*
+ *b:ale_python_black_auto_pipenv*
Type: |Number|
Default: `0`
@@ -263,6 +263,15 @@ to check for errors while you type.
`mypy` will be run from a detected project root, per |ale-python-root|.
+g:ale_python_mypy_auto_pipenv *g:ale_python_mypy_auto_pipenv*
+ *b:ale_python_mypy_auto_pipenv*
+ Type: |Number|
+ Default: `0`
+
+ Detect whether the file is inside a pipenv, and set the executable to `pipenv`
+ if true. This is overridden by a manually-set executable.
+
+
g:ale_python_mypy_executable *g:ale_python_mypy_executable*
*b:ale_python_mypy_executable*
Type: |String|
@@ -272,6 +281,7 @@ g:ale_python_mypy_executable *g:ale_python_mypy_executable*
Set this to `'pipenv'` to invoke `'pipenv` `run` `mypy'`.
+
g:ale_python_mypy_ignore_invalid_syntax
*g:ale_python_mypy_ignore_invalid_syntax*
*b:ale_python_mypy_ignore_invalid_syntax*
@@ -292,6 +302,14 @@ g:ale_python_mypy_options *g:ale_python_mypy_options*
invocation.
+g:ale_python_mypy_show_notes *g:ale_python_mypy_show_notes*
+ *b:ale_python_mypy_show_notes*
+ Type: |Number|
+ Default: `1`
+
+ If enabled, notes on lines will be displayed as 'I' (info) messages.
+
+
g:ale_python_mypy_use_global *g:ale_python_mypy_use_global*
*b:ale_python_mypy_use_global*
Type: |Number|
@@ -300,14 +318,6 @@ g:ale_python_mypy_use_global *g:ale_python_mypy_use_global*
See |ale-integrations-local-executables|
-g:ale_python_mypy_auto_pipenv *g:ale_python_mypy_auto_pipenv*
- *b:ale_python_mypy_auto_pipenv*
- Type: |Number|
- Default: `0`
-
- Detect whether the file is inside a pipenv, and set the executable to `pipenv`
- if true. This is overridden by a manually-set executable.
-
===============================================================================
prospector *ale-python-prospector*
diff --git a/test/handler/test_mypy_handler.vader b/test/handler/test_mypy_handler.vader
index 6e96f3f3..58d2b69e 100644
--- a/test/handler/test_mypy_handler.vader
+++ b/test/handler/test_mypy_handler.vader
@@ -1,6 +1,8 @@
Before:
Save g:ale_python_mypy_ignore_invalid_syntax
+ Save g:ale_python_mypy_show_notes
+ unlet! g:ale_python_mypy_show_notes
unlet! g:ale_python_mypy_ignore_invalid_syntax
runtime ale_linters/python/mypy.vim
@@ -69,6 +71,31 @@ Execute(The mypy handler should parse lines correctly):
\ '__init__.py:72:1: warning: Some warning',
\ ])
+Execute(The mypy handler should show notes if enabled):
+ call ale#test#SetFilename('__init__.py')
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 72,
+ \ 'col': 1,
+ \ 'filename': ale#path#Simplify(g:dir . '/__init__.py'),
+ \ 'type': 'I',
+ \ 'text': 'A note',
+ \ },
+ \ ],
+ \ ale_linters#python#mypy#Handle(bufnr(''), [
+ \ '__init__.py:72:1: note: A note',
+ \ ])
+
+ let g:ale_python_mypy_show_notes = 0
+
+ AssertEqual
+ \ [],
+ \ ale_linters#python#mypy#Handle(bufnr(''), [
+ \ '__init__.py:72:1: note: A note',
+ \ ])
+
Execute(The mypy handler should handle Windows names with spaces):
" This test works on Unix, where this is seen as a single filename
silent file C:\\something\\with\ spaces.py