I'm trying to use Mypy with Neomake, but without success. I am currently using flake8 with Neomake, and it works seamlessly, e.g.:

def foo(bar):
    return 1

foo(1) > E305 expected 2 blank lines after class or function definition, found 1

However, I am not getting warnings from Mypy:

def foo(bar: str) -> int:
    return 1


where I expect some sort of warnings at foo(1).

When I run Mypy outside of vim, I get an exepcted result:

test.py:5: error: Argument 1 to "foo" has incompatible type "int"; expected "str"

The following is the part of my (Neo)vim setting relevant to Neomake / python:

" make pyenv work with neovim
let g:python_host_prog = expand('~/.pyenv/versions/neovim-python2/bin/python')
let g:python3_host_prog = expand('~/.pyenv/versions/neovim-python3/bin/python')

" Neomake settings begin
call neomake#configure#automake('nrwi', 500)
" let g:neomake_tex_enabled_makers = ['chktex', 'rubberinfo', 'proselint']
let g:neomake_python_enabled_makers = ['flake8', 'mypy']
let g:neomake_python_flake8_maker = {
  \ 'exe': expand('~/.pyenv/versions/3.7.3/envs/neovim-python3/bin/flake8'),
  \ 'args': ['--format=default'],
  \ 'errorformat':
      \ '%E%f:%l: could not compile,%-Z%p^,' .
      \ '%A%f:%l:%c: %t%n %m,' .
      \ '%A%f:%l: %t%n %m,' .
      \ '%-G%.%#',
  \ 'postprocess': function('neomake#makers#ft#python#Flake8EntryProcess')
  \ }
let g:neomake_python_mypy_maker = {
  \ 'exe': expand('~/.pyenv/versions/3.7.3/envs/neovim-python3/bin/mypy'),
  \ }
" Neomake settings end

I tried with and without the latter three lines regarding g:neomake_python_mypy_maker, but nothing seems to change. Note that I use pyenv/virtualenv to encapsulate my vim settings.

How can I make Mypy to work within vim? Thanks in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.