ruff
e22718f2 - [`perflint`] Simplify finding the loop target in `PERF401` (#15025)

Commit
359 days ago
[`perflint`] Simplify finding the loop target in `PERF401` (#15025) Fixes #15012. ```python def f(): # panics when the code can't find the loop variable values = [1, 2, 3] result = [] for i in values: result.append(i + 1) del i ``` I'm not sure exactly why this test case panics, but I suspect the `del i` removes the binding from the semantic model's symbols. I changed the code to search for the correct binding by directly iterating through the bindings. Since we know exactly which binding we want, this should find the loop variable without any complications.
Author
Parents
Loading