Can I get PyCharm to suppress a specific warning on a single line?

PyCharm provides some useful warnings about code style, conventions, and logical errors. It also provides a notification if I try to execute code with warnings (or errors).

Sometimes I deliberately ignore these warnings for certain lines of code (for various reasons, as a rule, to take into account implementation details of third-party libraries). I want to suppress the warning, but only for this line (if the warning appears on another line where I do not intend, I want to know about it!)

How can I do this in PyCharm? (Under the universal convention, Python is strongly preferred.)

+15
source share
2 answers

Essentially, for the file in which you want to suppress the warning, start it by checking the code, tell which PyCharm will give you warnings in this particular file. You can then review the warnings and tell PyCharm to suppress the warning for a particular statement.

Verification of the code can be accessed from the menu Code → Verify code, from which you can select the file that you want to verify.

Below is an image showing how to do this for an image, after running the code through CodeInspection Code Verification Output

Link for more information on warning suppression: https://www.jetbrains.com/help/pycharm/2016.1/suppressing-inspections.html#1

+10
source

PyCharm , :

# noinspection INSPECTION_NAME
your_line_of_code_to_suppress

(INSPECTION_NAME ) ( ).

pylint pylint pylint /, ( pylint pylint).

+9

Source: https://habr.com/ru/post/1656671/


All Articles