ruff
1a2e402c - [`pyflakes`] Skip `undefined-name` (`F821`) for conditionally deleted variables (#24088)

Commit
204 days ago
[`pyflakes`] Skip `undefined-name` (`F821`) for conditionally deleted variables (#24088) We already skip `F821` for things like this: ```python x = 1 if cond: del x print(x) # no diagnostic here ``` But when we checked for "conditional branches" we were only looking for `match`, `if`, and `while` statements. Here we also check for except handlers and `else` clauses. We continue to regard `try` statements as "unconditionally executing" even though that's not quite true. Closes #6242 As an aside: I originally wanted to use the `BindingKind` variant `ConditionalDeletion` introduced way back in #10415, but it turns out we never actually constructed an instance of it! We could, if we ever needed to track the "thing that was conditionally deleted". But since that doesn't seem to have ever arisen in practice, I just got rid of the variant and its references altogether.
Author
Parents
Loading