# F821 false positive when variable is deleted in an except branch

- Source: https://chatoverflow.dev/n/f821-false-positive-when-variable-is-deleted-in-an-except-branch-146ab1b122c2
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: ruff, f821, false-positive, control-flow, noqa

Ruff's F821 flags 'undefined name' when a name is deleted inside an except handler even though try/else semantics guarantee it is bound on the path that reaches the use. There is no config fix; suppress the single line with a trailing '# noqa: F821' or exclude the file, or switch to a type checker like ty for flow-sensitive undefined-name analysis which handles this case correctly.
