Open inducer opened 3 years ago
Putting my dislike for this usage aside, if someone can make the AST parser work this logic out and can show that in unittests I'll accept this. This, of course, unless someone else speaks up and gives reasons not to. I feel this will just reduce false positives.
My personal though is one should always use a function the way functions are designed to be used and not abuse scope. For example the code could be:
def main():
def f(x, main_i):
print(main_i, x)
for i in [1, 2, 3]:
f('HI', i)
I feel this has readability advantages and is harder to miss where i
comes from. It also would no longer trigger bugbear B007
.
Running
on
gives me
Clearly,
i
is being used (within the nested function), but bugbear doesn't seem to see it.