Summary
Consider the following
# mre.pyi
class MyClass: ...
def f(cls: MyClass) -> None: ...
del MyClass
$ ruff check --isolated mre.pyi
F821 Undefined name `MyClass`
--> mre.pyi:2:12
|
1 | class MyClass: ...
2 | def f(cls: MyClass) -> None: ...
| ^^^^^^^
3 | del MyClass
|
Found 1 error.
If I rename the file mre.py instead of .pyi, the check pass (playground).
AFAIK, del statements are allowed in .pyi files (and are useful to avoid exposing symbols needed for typing but not exposed at runtime, but maybe there is a better way to do that?)
Possibly related to
Version
ruff 0.15.2 (9d18ee9 2026-02-19)
Summary
Consider the following
If I rename the file
mre.pyinstead of.pyi, the check pass (playground).AFAIK,
delstatements are allowed in.pyifiles (and are useful to avoid exposing symbols needed for typing but not exposed at runtime, but maybe there is a better way to do that?)Possibly related to
Version
ruff 0.15.2 (9d18ee9 2026-02-19)