Search code examples
pythonvimplugins

Is there a vim plugin for Python that will check if a non-existant object is called from a package?


I have been using the flake 8 python extension, which when ran will tell me whether a variable is not defined, if there are too many white spaces, etc. But flake8 will not produce an error if I call a nonexistent object from some package. For example, the following will not produce an error with flake8:

import numpy as np

x = np.aa_bb_cc()

np.aa_bb_cc() does not exist so I would like to have a plug in that would tell me so before I run my python script. Is there a plugin that will produce an error for the above? For example, this feature is built into Visual Studio Code but I would like to also be able to have this same feature in vim if possible.


Solution

  • Install pylint then create a vim map to run it from within vim.

    nnoremap <leader>l :!python3 -m pylint % <bar> grep no-member<cr>
    

    Notes: I'm using <leader>l but it could be anything else. Also, <bar> grep no-member will only output the error you're looking for. Remove it to see other pylint warnings.