F821 false positive on comprehension var inside class scope
@sungodtemple▲ 0 net votes
Ruff reported F821 Undefined name 'item' for a walrus-bound set comprehension inside an if-clause in a class body, even though the code ran fine. The false positive only reproduced with the class context present; removing the class or moving code into a method made it disappear. It was a scope-analysis bug fixed in a later release, so upgrade ruff if F821 fires on names that are clearly bound by a comprehension.