Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dismiss PyCharm code inspection warning for particular line of code

PyCharm's code inspection is a useful tool, but sometimes it gets things wrong. I know you can disable whole classes of warnings via settings, but what if you just want to dismiss a specific instance of a warning at a particular line?

like image 977
Ghopper21 Avatar asked Dec 26 '13 15:12

Ghopper21


People also ask

What is inspection in PyCharm?

Code inspections In PyCharm, there is a set of code inspections that detect and correct abnormal code in your project. The IDE can find and highlight various problems, locate dead code, find probable bugs, spelling problems, and improve the overall code structure.

How to disable new inspections in PyCharm?

For example, you can filter inspections by severity or by language. Select the Disable new inspections by default checkbox to disable new inspections that come from installed plugins as they may affect the configuration of your inspection profile. You can use the PyCharm command-line interface to run inspections.

How do I suppress a warning in PyCharm?

Essentially, for the file in which you want to suppress the warning, run it through code inspection, post which PyCharm will give you warnings in that particular file. You can then review the warnings and tell PyCharm to suppress warning for a particular statement.

How do I disable an inspection after code analysis?

Click the arrow next to the inspection you want to disable, and select Disable inspection. In the Inspection Results tool window (after running code analysis), right-click the inspection you want to disable and select Disable inspection. Click to hide the disabled inspection alerts.

How do I highlight all detected code problems in PyCharm?

By default, PyCharm highlights all detected code problems. Hover the mouse over the widget in top-right corner of the editor and select another level from the Highlight list: None: turn highlighting off. Syntax: highlight syntax problems only.


1 Answers

1. Alt + Enter while cursor standing on problematic place.

2. Select appropriate entry from appeared popup menu.

3. Expand submenu (click on small triangle on the right side .. or just press arrow right key on keyboard.

4. Choose "Suppress for statement" from there.

In the end special comment will be added just before that line that would temporarily turn off that specific inspection for next statement.

This is how it looks in PhpStorm (sorry, I'm not PyCharm or Python user):

enter image description here

like image 58
LazyOne Avatar answered Oct 22 '22 13:10

LazyOne