pyCharm:强制导入行不会变灰 [英] pyCharm: force import lines to not get grayed out

查看:31
本文介绍了pyCharm:强制导入行不会变灰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让其他模块方法可用.

I want to make an other modules method available.

from other_lib import foo_method

由于 foo_method 未在此文件中使用,因此该行变灰.

Since foo_method is not used in this file, it grayes out this line.

有没有办法阻止 pyCharm 这样做?

Is there a way to stop pyCharm from doing this?

推荐答案

提供此类信息的功能在 Intellij 平台上称为 Inspections.在这种情况下,似乎 Optimize 导入 已被分组在 Unresolved references 下(至少在 Pycharm 4 CE 中).

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. 使用键盘:将插入符号放在问题上,然后按 Alt + Enter,然后按 优化导入 |禁用检查.
  2. 从菜单中:首选项 |编辑 |检查,您可以在其中禁用未解析的引用.
  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.

如果你更愿意保留这个检查,因为它有其他有用的用途,并且只是在几个语句中禁用它,你可以Alt + Enter |优化进口 |抑制 for 语句.

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.

这篇关于pyCharm:强制导入行不会变灰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆