You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading to v0.0.262, I'm getting a false B031 error for multiple uses of a generator from itertools.groupby:
x = dict()
for key, group in itertools.groupby(x, lambda x: x):
if key:
for n in group:
print(n)
else:
list(group)
This code will result in B031 Using the generator returned from itertools.groupby() more than once will do nothing on the second usage. However, if I do not have a loop in the if block, I do not get the error, so as far as I can tell, it seems to be specific to loops (including comprehensions). This appears to be a case not caught by the fix in #3801
The text was updated successfully, but these errors were encountered:
Interesting! I see the problem. The global count is being increased instead of the branch local count. This leads to updating the global count twice which means that the line list(group) will be where this false positive is being detected at.
Let me take a look at it, I think even comprehensions might be affected.
After upgrading to v0.0.262, I'm getting a false B031 error for multiple uses of a generator from itertools.groupby:
This code will result in
B031 Using the generator returned from itertools.groupby() more than once will do nothing on the second usage
. However, if I do not have a loop in the if block, I do not get the error, so as far as I can tell, it seems to be specific to loops (including comprehensions). This appears to be a case not caught by the fix in #3801The text was updated successfully, but these errors were encountered: