我可以让PyCharm在一行上禁止显示特定警告吗? [英] Can I get PyCharm to suppress a particular warning on a single line?

查看:320
本文介绍了我可以让PyCharm在一行上禁止显示特定警告吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PyCharm提供有关代码样式,约定和逻辑陷阱的一些有用警告。如果我尝试提交带有警告(或错误)的代码,还会提供通知。

PyCharm provides some helpful warnings on code style, conventions and logical gotchas. It also provides a notification if I try to commit code with warnings (or errors).

有时候,我有意识地忽略了某些特定代码行的这些警告(由于各种原因,通常是以说明第三方库的实现详细信息)。我想禁止显示警告,但仅针对该行(如果警告出现在我不故意的其他行上,我想知道这一点!)

Sometimes I consciously ignore these warnings for particular lines of code (for various reasons, typically to account for implementation details of third-party libraries). I want to suppress the warning, but just for that line (if the warning crops up on a different line where I'm not being deliberate, I want to know about it!)

我如何在PyCharm中做到这一点? (最好遵循通用的Python约定。)

How can I do that in PyCharm? (Following a universal Python convention strongly preferable.)

推荐答案

要禁止对特定代码行进行PyCharm代码检查,您可以使用以下结构:

To suppress PyCharm code inspections for a particular line of code you can use the following construct:

# noinspection INSPECTION_NAME
your_line_of_code_to_suppress

其中检查的名称(上述 INSPECTION_NAME )可以从检查名称列表(描述性很强)。

where the name of the inspection (INSPECTION_NAME above) you can take from the list of inspection names (they are pretty descriptive).

禁止显示 pylint 命令行消息必须显式地使用不同的注释/命令,例如在此进行了描述 pylint 错误名称)。

To suppress pylint command line messages explicitly you have to use different comments/commands, as described here (pylint error names).

这篇关于我可以让PyCharm在一行上禁止显示特定警告吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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