关闭特定代码行的 PyCharm 代码检查警告 [英] Dismiss PyCharm code inspection warning for particular line of code

查看:76
本文介绍了关闭特定代码行的 PyCharm 代码检查警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PyCharm 的代码检查是一个有用的工具,但有时会出错.我知道您可以通过设置禁用整类警告,但是如果您只想在特定行中关闭警告的特定实例怎么办?

PyCharm's code inspection is a useful tool, but sometimes it gets things wrong. I know you can disable whole classes of warnings via settings, but what if you just want to dismiss a specific instance of a warning at a particular line?

推荐答案

1.Alt + Enter 光标停留在有问题的地方.

1. Alt + Enter while cursor standing on problematic place.

2.从出现的弹出菜单中选择适当的条目.

2. Select appropriate entry from appeared popup menu.

3.展开子菜单(单击右侧的小三角形...或只需按键盘上的向右箭头键.

3. Expand submenu (click on small triangle on the right side .. or just press arrow right key on keyboard.

4.从那里选择Suppress for statement".

最后会在该行之前添加特殊注释,暂时关闭对下一条语句的特定检查.

In the end special comment will be added just before that line that would temporarily turn off that specific inspection for next statement.

这是在 PhpStorm 中的样子(抱歉,我不是 PyCharm 或 Python 用户):

This is how it looks in PhpStorm (sorry, I'm not PyCharm or Python user):

这篇关于关闭特定代码行的 PyCharm 代码检查警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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