Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
asottile opened this issue Apr 24, 2021 · 2 comments
Open

Comments

@asottile
Copy link
Member

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
@sco1
Copy link

sco1 commented May 5, 2021

Did you already have something in mind to fix this?

If I'm following correctly (disclaimer: I'm new to Flake8's internals), the inline noqa check comes from this regex, is it desired to come up with a solution to this that fits into the regex? Or, maybe overthinking, can we do something like tokenize the line if the regex matches and check for a noqa comment (around here)?

@asottile
Copy link
Member Author

asottile commented May 5, 2021

yeah I'm planning to maybe rework this into a pipeline based on the tokenization (since that has to happen for linting anyway) -- I don't really want to shoehorn it into the existing structure as I'll probably be reworking that. I think the regex is still relevant but it should only be tested against COMMENT tokens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants