Question

I use this answer to run pylint from PY script. (I use pylint plugin similar to SublimeLinter, but no new process of Python is used, Python is embedded into Windows program). I see that even if I change source file, ie fixed errors, pylint still gives old messages.

E.g. I opened source code in editor, I have function w/out docstring, pylint shows this error. Now I add docstring, save file (I don't restart editor), and call pylint-plugin again - but pylint still gives "no docstring" error.

Any way to have actual error messages without restarting editor with pylint plugin? Any way to tell pylint "discard file cache"?

Was it helpful?

Solution

astroid (pylint's underlying library for AST) is holding a cache of ast per module. Try the code below to throw away the whole cache:

from astroid import MANAGER
MANAGER.astroid_cache.clear()

Relevant issue: https://github.com/PyCQA/pylint/issues/158

OTHER TIPS

Using pylint in vscode on Windows with similar issues:

  1. go to C:\Users[my username].pylint.d directory
  2. delete the .stat files making problems
  3. restart vscode
  4. trigger pylint again

Note: In my case I renamed a file from uppercase to lowercase. Then I got the result

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top