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?
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.
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.
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.
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.
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. 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):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With