landscapeio / prospector

Inspects Python source files and provides information about type and location of classes, methods etc
GNU General Public License v2.0
1.93k stars 171 forks source link

Support for PyCharm's "noinspection" error suppression markers. #275

Open techdragon opened 6 years ago

techdragon commented 6 years ago

In the absence of a standard for error suppression marks/comments, since Prospector supports the use of #noqa from pep8 and pyflakes, as well as #pylint comments, support PyCharm's suppression comments, which are similar to the new style symbolic name pylint ones.

This gist contains a script that shows how we can extract the current ones for the purposes having a way to check when new ones have been added without trial and error, as well as providing a reference list of the current error suppression markers that will need to be supported.

I'm raising this here, since I'm not sure the best way to get the support across all of the tools supported by prospector. Since there are going to be various tool inspection priorities that affects which tools will need to support which annotations.

Edit 1

It might even be possible to support the PyCharm syntax for ignoring certain things in an entire file inside prospector itself, as this is normally at the top of files and might be easy enough for Prospector to inspect itself.

carlio commented 6 years ago

This kind of logic is handled here https://github.com/PyCQA/prospector/blob/master/prospector/suppression.py - so adding some extra directives might be enough.

This is also a little bit related to the logic in the postfilter here - https://github.com/PyCQA/prospector/blob/master/prospector/postfilter.py

I won't have time to look into this for a while, just adding this comment for anyone who wants to make a PR (hint hint ;-) )

techdragon commented 6 years ago

@carlio Thanks for the very helpful links to the appropriate sections of the code. From the look of things, it should be possible to get what I want just by adding some more code to suppression.py and even the feature I was worried would be a large effort might actually just be a simple matter of extending get_suppressions with another section of code similar to https://github.com/PyCQA/prospector/blob/master/prospector/suppression.py#L107-L116 but for PyCharm's suppressions. I should have some time to cook up a PR in the next couple of weeks.