2

I'm using the PyCharm (Python plugin) on IntelliJ Ultimate.

Normally the IDE highlights any undefined identifiers with a red-underline, but I've noticed that on some projects this feature stops working.

Red-underlines are really useful because they allow me to use IntelliJ's auto-fixes (e.g. importing or creating a missing function/class).

Just about every other PyCharm feature I can think of seems to still be working. For example, AutoComplete works just fine.

Sometimes if I set the project's SDK to , and then set it back to the correct Python interpreter the project starts to highlight NameErrors correctly. This doesn't seem to work consistently. I'm using Conda, and I've tried setting up Conda envs as normal virtualenvs, or as "system interpreters".

I've searched the log files and cannot see anything that might indicate the plugin failed to initialize.

In most cases (except for when the system briefly decides to work), I get no red underlines but all of the other PyCharm features seem to work normally. Furthermore, this only seems to affect Python: Scala and Java code behaves exactly as you might expect it to work in IntelliJ.

Is there a way to debug this? What's going wrong? How do I fix it?

Auto-complete is still working, but the red underline on nonsense code is missing

Unresolved References inspection is switched on

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Salim Fadhley
  • 6,975
  • 14
  • 46
  • 83

1 Answers1

2

I've had this same problem with the symptons you describe. From the description the cause is that you have "Reader Mode" enabled.

Normally the IDE highlights any undefined identifiers with a red-underline, but I've noticed that on some projects this feature stops working.

The red underline/scribble for errors is suppressed for modules that are currently installed in the projects virtual environment or interpreter. (This makes sense because if for some reason you want to read code from an installed library it's usually not your concern if the library author made mistakes or if that library code for example issues warnings according to your code style settings, etc...)

Sometimes if I set the project's SDK to , and then set it back to the correct Python interpreter the project starts to highlight NameErrors correctly.

If you change the project SDK to an interpreter that does not have your modules installed the errors will be shown again. You can set the display of errors with Reader Mode enabled checking the option at File > Settings > Editor > Reader Mode > Error and warning highlighting, inspection widget. As shown in the screenshot

screenshot PyCharm reader mode

If you disable Reader Mode the IDE will also again issues errors as usual.

bad_coder
  • 11,289
  • 20
  • 44
  • 72