PyCQA / PyCQA/flake8

flake8 should only consider a noqa comment if it is actually a comment

Open
#1,321 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug:confirmed confirmed-by:core
Dominant language
Python
Stars
3.8k
Forks
356
PR merge metrics
No merged PRs in 30d

Description

minimal reproduction:

def f():
    x = '# noqa'

I expect this to report the same as if that were an unrelated string:

def f():
    x = '......'
$ flake8 unrelated.py
unrelated.py:2:5: F841 local variable 'x' is assigned to but never used

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal Python reproduction in the issue and run the shown flake8 unrelated.py command to observe the false suppression. Trace how flake8 decides whether # noqa is a comment, then add a regression test showing that the string literal does not suppress F841; done means the warning matches the unrelated-string example.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.