plinss / flake8-noqa

flake8 plugin to validate #noqa comments - Mirror of https://gitlab.linss.com/open-source/flake8/flake8-noqa
GNU Lesser General Public License v3.0
40 stars 6 forks source link

Incorrect NQA102 error #21

Closed nkakouros closed 1 year ago

nkakouros commented 1 year ago

I have a library file that I am checking with vulture. For a function that I define in there, I get the following error from vulture:

my-lib.py:12: unused function 'method-name' (60% confidence)

I can silence this with noqa VT103. But then flake8-noqa will complain:

NQA102 "# noqa: VT103" has no matching violations
stefan6419846 commented 1 year ago

Isn't this duplicated by the (more detailed) #22?

nkakouros commented 1 year ago

Isn't this duplicated by the (more detailed) #22?

No, this is about the false positive. Issue #22 is about silencing NQA errors.

plinss commented 1 year ago

This is likely a duplicate of #2. This happens when the plugin itself respects # noqa comments and stops sending the error to flake8. This is an anti-pattern and the proper behavior is for the plugin to just send it's errors regardless and trust flake8 to do the suppression.

If you're using vulture stand-alone, then flake8 and by extension flake8-noqa will never see the error and so will always complain. The ideal fix here is to use vultureas a flake8-plugin (which may require someone writing a plugin) and adding a switch to vulture to ignore # noqa comments when used as a plugin.

nkakouros commented 1 year ago

I see. I found this issue on vulture's issue tracker where they discussed making vulture a flake8 plugin, but this required support from upstream flake8 which was hostile to the idea. Does this mean that the only way forward for vulture users is #22?

plinss commented 1 year ago

Yes, if the errors aren't reported through flake8, there's no way for flake8-noqa to know if an error exists on a line or not.

I'm going to close this issue and give some thought to #22, at this point I'm thinking a config option to specify codes to ignore NQA102 errors on (I'd rather not add any additional info to the comments). It'll also help as a work around for plugins that do their own # noqa processing.