leinardi / mypy-pycharm

A plugin providing both real-time and on-demand scanning of Python files with Mypy from within PyCharm/IDEA.
Apache License 2.0
194 stars 31 forks source link

Honour noinspection comments #4

Closed grvhi closed 6 years ago

grvhi commented 6 years ago

Is your feature request related to a problem? Please describe. Perhaps this is a bug, but I'm not sure... Basically, it would be nice if the plugin's scan results honoured # noinspection Mypy

Describe the solution you'd like Any lines of code which are preceded by # noinspection Mypy should be ignored by the plugin and therefore any errors/warnings mypy finds in those lines should not appear in the results panel.

Additional context It seems that either PyCharm or this plugin does correctly suppress warnings within the editor window. See attached screenshots for an unsuppressed warning in the editor, the suppression of that warning, and the warning persisting in the scan panel (after re-running a scan)

screen shot 2018-09-03 at 13 53 42 screen shot 2018-09-03 at 13 53 52 screen shot 2018-09-03 at 13 54 00

leinardi commented 6 years ago

Hi @grvhi, thank you for your report. Unfortunately it will be quite complex to handle this feature on the plugin level, because the plugin is just a front end for mypy: all the validation is done from the same CLI tool that you would use without this plugin. This means that if you want to ignore a specific line of code, this has to be supported directly by mypy, because the plugin is just providing the list of files to scan, and not the actual lines of code.

As far as I know mypy uses the PEP 484 # type: ignore (see here for details), you could use that as workaround to ignore some specific line.

grvhi commented 6 years ago

Thanks @leinardi - that seems to work (using # type: ignore instead of # noinspection Mypy)