Disable inspection in PyCharm

廉价感情. 提交于 2021-01-29 10:57:41

问题


There are several articles explaining how to disable inspection in PyCharm by clicking my way around. I do not like that because:

  • It does not work for me
  • I have no idea what PyCharm is doing
  • I want to disable PEP8 checking in certain cases, and not be bound to PyCharm

In flake8 I can ignore errors with # noqa, but PyCharm does not seem to respect that consistently.

How can I tell (in code) PyCharm to ignore errors in a specific line of code?


回答1:


If you click alt+enter on the errors, you can see some choices.

For example, Suppress for class, Suppress for function, Suppress for statement.

You can choose one of them to suppress specific inspection or totally disable inspection for a given scope.

And also you can use # noinspection xxx to suppress inspection (The same as above).

For example, to suppress PyBroadException, you can use # noinspection PyBroadException. To totally disable inspection, you can use # noinspection All.




回答2:


PyCharm 2020.1 and later recognize # noqa style suppressions! https://blog.jetbrains.com/pycharm/2020/02/pycharm-2020-1-eap-4/



来源:https://stackoverflow.com/questions/51148206/disable-inspection-in-pycharm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!