问题
I want to make an other modules method available.
from other_lib import foo_method
Since foo_method
is not used in this file, it grayes out this line.
Is there a way to stop pyCharm from doing this?
回答1:
The feature giving this kind of information is called Inspections
on Intellij platforms. In this case, it seems that Optimize imports
has been grouped under Unresolved references
(at least in Pycharm 4 CE).
You can disable this inspection once for all, yet be aware that in-code inspections of unresolved references (eg. attributes), will also be disabled. There are at least two ways:
- With the keyboard : put the caret on the problem and press
Alt + Enter
thenOptimize imports | Disable inspection
. - From the menu :
Preferences | Editor | Inspections
where you can disableUnresolved references
.
If you'd rather keep this inspection since it has other useful usages, and just disable it for a couple of statements, you can Alt + Enter | Optimize imports | Suppress for statement
.
来源:https://stackoverflow.com/questions/27223724/pycharm-force-import-lines-to-not-get-grayed-out