PyCharm noinspection for whole file?(PyCharm noinspection 对整个文件?)
问题描述
是否可以在 PyCharm 中禁用对整个文件的检查?
需要这样做的原因是在处理
Is it possible to disable an inspection for the whole file in PyCharm?
The reason this is needed is when dealing with py.test. It uses fixtures which appear to shadow function parameters, and at the same time cause unresolved references. e.g.:
from myfixtures import user # Unused import statement warning
def test_is_awesome(user): # Shadows name 'user' from outer scope warning
assert user.is_awesome()
There is also other warnings from py.test, such as using pytest.raises() causes a "Can not find reference 'raises'" in pytest.py.
Maybe there's another way to fix these problems? Maybe I'm using py.test incorrectly?
Is it possible to disable an inspection for the whole file in PyCharm?
Yes. This answer is for this question only (and not about "Maybe there's another way to fix these problems? Maybe I'm using py.test incorrectly?").
- "Settings | Scopes"
- Create new scope that would include such "unwanted" file(s)
- "Settings | Inspections"
- Find "problematic" inspection
- Right click and choose "Add scope"
- Disable that inspection for that specific scope
Alternatively (may work or may not: depends on actual inspection .. and I'm not sure if it actually works in PyCharm this way -- not a PyCharm user myself unfortunately)
- Alt + Enter while caret is standing on error/warning place in your code
- Select correct entry from appeared popup menu
- Using Arrow Right key expand submenu
- Look for "Suppress inspection" option
This is how it looks in PhpStorm (screenshot shows "suppress for statement" option and not "suppress for whole file"):
Related: https://stackoverflow.com/a/20803118/783119
这篇关于PyCharm noinspection 对整个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PyCharm noinspection 对整个文件?
基础教程推荐
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
