Can I get PyCharm to suppress a particular warning on a single line?(我可以让 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
您可以从 检查名称列表(它们非常具有描述性).
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 在一行中抑制特定警告吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我可以让 PyCharm 在一行中抑制特定警告吗?


基础教程推荐
- 修改列表中的数据帧不起作用 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 包装空间模型 2022-01-01
- 求两个直方图的卷积 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01