4

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"?

Community
  • 1
  • 1
Prog1020
  • 4,530
  • 8
  • 31
  • 65
  • I tried this. Before accessing pylint, i deleted pylint and "pylint.nnnnnnnnn" (if exist) from sys.modules. This doesn't give good, because on second access to pylint api, it gave empty result. I mean function from my URL, it gave empty pylint output if I did this. (It was only one place where i accessed pylint api) – Prog1020 Mar 08 '14 at 20:28

2 Answers2

4

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

Community
  • 1
  • 1
sthenault
  • 14,397
  • 5
  • 38
  • 32
2

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

vincent
  • 21
  • 2