pyCharm: force import lines to not get grayed out

笑着哭i 提交于 2021-02-07 18:47:29

问题


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:

  1. With the keyboard : put the caret on the problem and press Alt + Enter then Optimize imports | Disable inspection.
  2. From the menu : Preferences | Editor | Inspections where you can disable Unresolved 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!