2

When editing python files in VS Code, the parser will sometimes start mis-identifying parser errors in code. The editor still works, Interactive Python window still runs the code, etc. Example:

parser-error

There is no actual code error here, but the parser choked on a closing parenthesis and then decided that every line after this one is invalid. The parser generates dozens of 'invalid token' errors, and the only way to fix it that I have found is to close and reopen VS Code. Closing the file keeps the error list in the folder window, and reopening the file shows the false errors again.

Is there a way to restart the Python parser without restarting VS Code, and preferably without restarting the iPython engine?

user15741
  • 764

1 Answers1

2

This same problem has been raised many times on the VS Code Support forums without a good solution : The error messages are not erased and there is no user method for clearing the Problems pane except restarting VS Code or recompiling.

Here are a couple of posts about the subject, both from November 2018, which also contain cross-references to similar more posts saying the same thing:

The only workaround, which is a bit less onerous than a total restart (although finally having the same effect), is to press Ctrl+Shift+P for entering the Command Palette and typing the command Reload Window.

Another command used for such cases is "C/C++ Reset IntelliSense database", which may not apply to Python. Type reset in the Command Palette and see if in the popup list you can find some option that is useful in your case.

harrymc
  • 498,455