2017-04-29 12:33:18 -04:00
|
|
|
Before:
|
2018-01-11 11:43:10 -05:00
|
|
|
Save g:ale_python_mypy_ignore_invalid_syntax
|
|
|
|
|
|
|
|
unlet! g:ale_python_mypy_ignore_invalid_syntax
|
|
|
|
|
2017-01-20 12:30:23 -05:00
|
|
|
runtime ale_linters/python/mypy.vim
|
|
|
|
|
2017-09-11 17:25:15 -04:00
|
|
|
call ale#test#SetDirectory('/testplugin/test/handler')
|
|
|
|
|
2017-04-29 12:33:18 -04:00
|
|
|
After:
|
2018-01-11 11:43:10 -05:00
|
|
|
Restore
|
|
|
|
|
2017-09-11 17:25:15 -04:00
|
|
|
call ale#test#RestoreDirectory()
|
2017-04-29 12:33:18 -04:00
|
|
|
call ale#linter#Reset()
|
|
|
|
|
|
|
|
Execute(The mypy handler should parse lines correctly):
|
2017-09-11 17:25:15 -04:00
|
|
|
call ale#test#SetFilename('__init__.py')
|
2017-05-06 18:19:54 -04:00
|
|
|
|
2017-01-20 12:30:23 -05:00
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
2017-08-20 12:43:42 -04:00
|
|
|
\ 'lnum': 768,
|
|
|
|
\ 'col': 38,
|
2017-12-19 13:23:09 -05:00
|
|
|
\ 'filename': ale#path#Simplify(g:dir . '/baz.py'),
|
2017-08-20 12:43:42 -04:00
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'Cannot determine type of ''SOME_SYMBOL''',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 821,
|
|
|
|
\ 'col': 38,
|
2017-12-19 13:23:09 -05:00
|
|
|
\ 'filename': ale#path#Simplify(g:dir . '/baz.py'),
|
2017-08-20 12:43:42 -04:00
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'Cannot determine type of ''SOME_SYMBOL''',
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 38,
|
|
|
|
\ 'col': 44,
|
2017-12-19 13:23:09 -05:00
|
|
|
\ 'filename': ale#path#Simplify(g:dir . '/other.py'),
|
2017-08-20 12:43:42 -04:00
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'Cannot determine type of ''ANOTHER_SYMBOL''',
|
|
|
|
\ },
|
|
|
|
\ {
|
2017-05-06 18:19:54 -04:00
|
|
|
\ 'lnum': 15,
|
|
|
|
\ 'col': 3,
|
2017-12-19 13:23:09 -05:00
|
|
|
\ 'filename': ale#path#Simplify(g:dir . '/__init__.py'),
|
2017-01-20 12:30:23 -05:00
|
|
|
\ 'type': 'E',
|
2017-08-20 12:43:42 -04:00
|
|
|
\ 'text': 'Argument 1 to "somefunc" has incompatible type "int"; expected "str"'
|
2017-01-20 12:30:23 -05:00
|
|
|
\ },
|
2017-02-04 14:47:37 -05:00
|
|
|
\ {
|
2017-05-06 18:19:54 -04:00
|
|
|
\ 'lnum': 72,
|
|
|
|
\ 'col': 1,
|
2017-12-19 13:23:09 -05:00
|
|
|
\ 'filename': ale#path#Simplify(g:dir . '/__init__.py'),
|
2017-05-06 18:19:54 -04:00
|
|
|
\ 'type': 'W',
|
2017-08-20 12:43:42 -04:00
|
|
|
\ 'text': 'Some warning',
|
2017-02-04 14:47:37 -05:00
|
|
|
\ },
|
2017-01-20 12:30:23 -05:00
|
|
|
\ ],
|
2017-05-06 18:19:54 -04:00
|
|
|
\ ale_linters#python#mypy#Handle(bufnr(''), [
|
2017-09-11 17:25:15 -04:00
|
|
|
\ 'baz.py: note: In class "SomeClass":',
|
|
|
|
\ 'baz.py:768:38: error: Cannot determine type of ''SOME_SYMBOL''',
|
|
|
|
\ 'baz.py: note: In class "AnotherClass":',
|
|
|
|
\ 'baz.py:821:38: error: Cannot determine type of ''SOME_SYMBOL''',
|
|
|
|
\ '__init__.py:92: note: In module imported here:',
|
|
|
|
\ 'other.py: note: In class "YetAnotherClass":',
|
|
|
|
\ 'other.py:38:44: error: Cannot determine type of ''ANOTHER_SYMBOL''',
|
|
|
|
\ '__init__.py: note: At top level:',
|
|
|
|
\ '__init__.py:15:3: error: Argument 1 to "somefunc" has incompatible type "int"; expected "str"',
|
2017-05-06 18:19:54 -04:00
|
|
|
\ 'another_module/bar.py:14: note: In module imported here,',
|
|
|
|
\ 'another_module/__init__.py:16: note: ... from here,',
|
2017-09-11 17:25:15 -04:00
|
|
|
\ '__init__.py:72:1: warning: Some warning',
|
2017-01-20 12:30:23 -05:00
|
|
|
\ ])
|
|
|
|
|
2017-04-29 12:33:18 -04:00
|
|
|
Execute(The mypy handler should handle Windows names with spaces):
|
2017-05-06 18:19:54 -04:00
|
|
|
" This test works on Unix, where this is seen as a single filename
|
|
|
|
silent file C:\\something\\with\ spaces.py
|
|
|
|
|
2017-04-29 12:33:18 -04:00
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 4,
|
|
|
|
\ 'col': 0,
|
2019-06-05 09:16:43 -04:00
|
|
|
\ 'filename': ale#path#Simplify('C:\something\with spaces.py'),
|
2017-04-29 12:33:18 -04:00
|
|
|
\ 'type': 'E',
|
2017-08-20 12:43:42 -04:00
|
|
|
\ 'text': 'No library stub file for module ''django.db''',
|
2017-04-29 12:33:18 -04:00
|
|
|
\ },
|
|
|
|
\ ],
|
2017-05-06 18:19:54 -04:00
|
|
|
\ ale_linters#python#mypy#Handle(bufnr(''), [
|
|
|
|
\ 'C:\something\with spaces.py:4: error: No library stub file for module ''django.db''',
|
2017-04-29 12:33:18 -04:00
|
|
|
\ ])
|
2018-01-11 11:43:10 -05:00
|
|
|
|
|
|
|
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',
|
|
|
|
\ ])
|