question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Forbid unused `noqa` comments

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:6
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
maltevespercommented, Mar 21, 2021

I think there is another related option: https://pypi.org/project/flake8-noqa/

1reaction
aleksey-sergeycommented, Sep 21, 2021

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”!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I get Pyflakes to ignore a statement? - Stack Overflow
Tips # noqa: F841 means ignoring only F841 error at the line. – SangminKim. Feb 12, 2018 at 16:00. | Show 6 more...
Read more >
Ignoring Errors with Flake8 — flake8 3.1.1 documentation
If we ever want to disable Flake8 respecting # noqa comments, we can can refer to flake8 --disable-noqa . If we instead had...
Read more >
noqa does not suppress the warning for flake8
I still want to see the warning for unused imports but if I use # noqa I want them ... which will allow...
Read more >
Common issues and solutions - mypy 0.991 documentation
You can add a # type: ignore comment to tell mypy to ignore this error: ... to silence complaints about unused imports from...
Read more >
Remove Unused Imports & Unused Variables from Python Code
To prevent that, without having to exclude the entire file, you can add a # noqa comment at the end of the line,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found