PyCharm code inspection not working

I recently upgraded to PyCharm Professional 2020.3.2 on Mac OS Catalina 10.15.7.  When I did that it disabled code inspection for the project I had open at the time I upgraded.  It is odd that it is only one project that code inspection seems to be disabled on.  I checked the preferences and almost all the settings under Preferences->Editor->Inspections for python are checked.  If I open another project the code inspection works.

One simple example of a code inspection that is not working is adding an import for a package that is not used.  Previously I would see PEP8 warnings as well is the line highlighted in some manner to indicate the import is unused.

Here is what I've tried to date that hasn't worked:

  • Exit out of pycharm completely and restart
  • Downgrade back to previous version (2020.3)
  • Recreated the project code inspection is not working in
  • Restore the settings to the default settings (File->Manage IDE Settings->Restore Default Settings)
17 comments
Comment actions Permalink

Hi, could you please provide screenshot demonstrating the issue, and a screenshot of your project structure. 

Also, is it possible to provide minimal sample of the affected project? (e.g., if you remove most of the code and leave only code necessary to reproduce the issue).

0
Comment actions Permalink

Hi, I had the same issue. I tried also different things on my project settings. In the end via File -> Invalidate Caches / Restart ... could solve this problem. Now the inspection works as expected. Maybe this could help you.

0
Comment actions Permalink

Thanks for the suggestion Steffi.  I tried the File -> Invalidate Caches / Restart but that did not resolve the problem for me.

0
Comment actions Permalink

Andrey,

Here is an example of a working file marking an import as unused

Here is an example where the import is not marked as unused

Here is an example of an unused variable properly marked as such

Here is an example where the unused variable is not marked

What exactly are you looking for as far as the project structure?  Not sure I can easily provide you the minimal sample as it is a rather large project.  I can see if I can make a copy and reduce it down to a few files that allow me to reproduce the problem.  Will let you know if I'm able to do that.

Keith

 

 

0
Comment actions Permalink

>What exactly are you looking for as far as the project structure?

Want to make sure the source dir is not excluded, not inside venv dir, e.t.c.

Is interpreter configured correctly, can you run the code?

Make sure that:

- Power save mode is not enabled in File menu

- Highlight level is set to all problems

Try disabling reader mode in **Preferences | Editor | Reader Mode**

0
Comment actions Permalink

I copied my project to another directory and then created a new pycharm project using the new directory.  When the new project was created all the code inspection worked as expected.  This seems to indicate there are some project related settings being saved somewhere. 

How would I go about deleting all pycharm related project files so I could in essence start over from scratch similar to copying the files to a new directory and creating a new project from there?

I deleted the .idea file in the root directory of my project and removed the project from recent projects but that did not clear things up.

0
Comment actions Permalink

Hi Andrey, Power save mode was not enabled and disabled reader mode.  Neither of those made a difference.  I couldn't locate the Highlight level setting you showed.  How do you navigate to that?

One thing I did try was selecting Navigate->Next Highlighted Error and that seemed to fix things.

Hope that may help figure out what may have triggered this problem.

0
Comment actions Permalink

Schomburg, Keith I've got exactly the same problem with only one of my projects, the one that I was working on when I updated Pycharm and restarted. I tried to invalidate caches and it didn't work. I tried all the ideas by Andrey Resler and it didn't solve the problem. I also removed the entire ".idea/ " directory in the project base and restored all settings to default and still it didn't solve it. supper strange and annoying.

0
Comment actions Permalink

Mrezzamoradi Please make sure the **Preferences | Editor | Reader Mode** is disabled, and if this doesn't help, I suggest to submit a bug report to https://youtrack.jetbrains.com/issues/py with Logs from **Help | Collect Logs and Diagnostic Data**

0
Comment actions Permalink

Andrey Resler Thanks for your suggestions. It is not in Reader Mode, and I cannot reproduce it to submit a bug report. Interestingly an exact copy of the project doesn't have this issue (copy via "cp -a"). More interestingly the issue appears again if you rename the copied directory back to the original directory name. I had another issue with the same project regarding font ligatures and copying solved that too. Here's a bug report for that one https://youtrack.jetbrains.com/issue/PY-46023

 
0
Comment actions Permalink

Invalidate caches didn't work for me, but I solved this problem by switching to a new Python Interpreter.

1
Comment actions Permalink

I have the same problem, started recently with the new version 2021.2
If I restart PyCharm inspections works perfect, but after a while of coding, inspections crash and stop working, sometimes to solve this I have to select other interpreter and than select back the olther one, I also tried to reinstall everything from scratch, PyCharm + venv and same problem.

0
Comment actions Permalink

Hello @Vali, 

it would be great to investigate this. Please submit a report at

https://youtrack.jetbrains.com/issues/PY , attach a couple of screenshots and

logs folder zipped from ***Help | Collect logs and Diagnostic Data*** . 

 

 

 

0
Comment actions Permalink

Hey, I had the same problem. Thanks for all the helpful suggestions. However in my case they didn't work.

I found the solution when I realized the icons next to my .py files did not include the python logo:

This is the icon for normal text files but normally the icon for python files look like this:

Here are some ways how this can be solved:

https://stackoverflow.com/questions/11687302/pycharm-not-recognizing-python-files

0
Comment actions Permalink

I have the problem as well but is solved when I restart with invalidating the cache. I work with very large projects and it seems to happen when I make major refactors that need reindexing or when I am making changes to the code mid execution in debug mode.  

0
Comment actions Permalink

I faced the same problem. I noticed it after I hastily/inadvertently clicked on one of those contextual lightbulb suggestions.

Tried invalidating caches, deleting .idea folder in project to no avail.

I solved it by resetting inspections to IDE defaults in settings. In my case it made sense because I don't really mess about with inspections. Also restarted with invalidate caches just to be sure but it may not have been necessary.

If you have some inspections adjustments of your own, you could then go back and turn them on or off as need be, on set them in context as you code.

Hope this helps.

0

Please sign in to leave a comment.