wemake-python-styleguide
wemake-python-styleguide copied to clipboard
Forbid unused `noqa` comments
Rule request
Thesis
We should raise a warning when noqa
comment is unused.
However, I am not sure that this is possible without patching flake8
.
Reasoning
Consider this example:
some_variable = 12 # noqa: A001
A001
means that your name overrides some python
builtin.
But, it does not look like so. Or does it?
This kind of errors happen to have historical roots. At some point in time they were actually used, but then the code was refactored. But the comment was left untouched.
See https://github.com/snoack/flake8-per-file-ignores/blob/master/flake8_per_file_ignores.py#L61-L65
This is already implemented. We just need to copy this logic.
Related: https://github.com/asottile/yesqa
We can also warn about unused ignore=
and per-file-ignores=
I think there is another related option: https://pypi.org/project/flake8-noqa/
I think there is another related option: https://pypi.org/project/flake8-noqa/ It's a nice package indeed. Added it to one of my projects and it "just worked"!
I am really interested in this. It is also useful to remove the silencing of false positives when they are fixed.
@vnmabus May be just use flake8-noqa?