Suppose I del a variable in an Exception branch:
def my_fn(a: str) -> str:
try:
print(a)
except Exception:
del a
raise
else:
return a
a must always exist in the else branch, but Ruff claims it's undefined:
~$ ruff foobar.py --isolated
foobar.py:8:16: F821 Undefined name `a`
Found 1 error.
(line 8 char 16 is the location of the a in the return statement)
This is on version 0.0.281:
~$ ruff --version
ruff 0.0.281