문제

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

도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top