问题
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