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

B031 false positive when reassigning the returned generator #395

Open
tomasr8 opened this issue Jun 28, 2023 · 0 comments
Open

B031 false positive when reassigning the returned generator #395

tomasr8 opened this issue Jun 28, 2023 · 0 comments

Comments

@tomasr8
Copy link
Contributor

tomasr8 commented Jun 28, 2023

Code to reproduce:

from itertools import groupby

for _, gen in groupby([]):
    gen = list(gen)
    print(gen)

This wrongly triggers B031 even though the generator is indeed saved to a list as suggested
in the error message. You can make the error go away by assigning to a new variable so
maybe not worth it to track reassignments?

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

No branches or pull requests

1 participant