How to enable "unused imports" in PyCharm

My PyCharm does not mark imports as unused.

Me ( os

not used):

enter image description here

It should be (find this image on the internet):

enter image description here

How do I enable it?

+3


source to share


3 answers


I couldn't find the answer anywhere, so I just completely reinstalled PyCharm without IDE import options and deleted the project settings in the project folder.



The "unused imports" are now highlighted.

+1


source


None of the existing answers worked for me.

However, I noticed that the file I was having the problem with was outside the project (one .py file opened directly from File-> Open). For some reason, even marking global imports as unused doesn't work.



Adding the file to the project solves the problem.

+2


source


For the next person who comes across this, the following might help:

  • Click "File";

  • Click "Invalidate Caches / Restart ..."

  • Click "Invalidate and Restart"

This can fix the issue where unused imports are not displayed.

+1


source







All Articles