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?
Asked
Active
Viewed 5,030 times
14
-
1**Not sure if it actually works like this in PyCharm** (not using this particular JetBrains IDE) but please try: 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 `arrow right` key on keyboard; 4) Choose `Suppress for statement` from there. This is how it looks in **PhpStorm**: http://postimg.org/image/o4xvaapv3/ – LazyOne Dec 27 '13 at 12:28
-
@LazyOne - yes, that works, thanks! – Ghopper21 Dec 27 '13 at 14:05
-
An example of pyCharm getting it wrong is when you're using class properties and it hollars at you for not defining attributes outside of init, i.e. in init you have `self.my_property` and in the setter you do `self._my_property` By the way, it's just `option+enter` if you're on a mac. – RYS Sep 03 '15 at 10:53
1 Answers
15
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):
LazyOne
- 148,457
- 42
- 363
- 369
-
3Emphasis on typing **right-arrow**. In PyCharm 4.5 clicking the small triangle does not work to install a `# noinspection` comment. Instead it engages the default solution. – Bob Stein May 15 '15 at 18:00