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 在一行中抑制特定警告吗?


- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01