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
(Example is somewhat nested loop focused as that's what I thought the problem was initially)
Interestingly, PERF102 does trigger with this example, but I think only because it doesn't process comprehensions at all? If it's expanded out the warning goes away.
The only thing of note from ALL is PLW2901, which detects the variable shadowing.
dylwil3
changed the title
B007 does not detect unused variables when they are shadowed
B007 does not detect unused variables when they are shadowed or appear in inner scope
Nov 5, 2024
I guess technically my previous example wasn't "shadowing", but an issue of scope. But shadowing also doesn't work (as you showed well in your original example):
forkinls:
k=2
But, as you also point out, this is caught by PLW2901.
B007 (unused-loop-control-variable) does not trigger when variables are shadowed.
See this extremely contrived example:
https://play.ruff.rs/92ded63b-80d4-4d7d-989a-3460865af51b
(Example is somewhat nested loop focused as that's what I thought the problem was initially)
Interestingly, PERF102 does trigger with this example, but I think only because it doesn't process comprehensions at all? If it's expanded out the warning goes away.
The only thing of note from ALL is PLW2901, which detects the variable shadowing.
Related issues: #8786 #9454 #10723
ruff 0.7.2
The text was updated successfully, but these errors were encountered: