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

False Positive: walrus in a list comprehension #800

Closed
bradezard131 opened this issue Feb 1, 2024 · 6 comments · Fixed by #801
Closed

False Positive: walrus in a list comprehension #800

bradezard131 opened this issue Feb 1, 2024 · 6 comments · Fixed by #801

Comments

@bradezard131
Copy link

Minimal reproduction:

def foo(x):
    fns = [lambda x: x + 1, lambda x: x + 2, lambda x: x + 3]
    return [(x := fn(x)) for fn in fns]

This raises F841 incorrectly asserting that the x variable assigned in the comprehension is never used

@asottile
Copy link
Member

asottile commented Feb 1, 2024

what version are you using?

@bradezard131
Copy link
Author

pyflakes==3.2.0 which afaict is the latest?

@sigmavirus24
Copy link
Member

What version of python are you running on?

@bradezard131
Copy link
Author

Python 3.10.12

@asottile
Copy link
Member

please try out #801

@bradezard131
Copy link
Author

Yep that fixes it for me

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

Successfully merging a pull request may close this issue.

3 participants