-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
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
- F821 false positive for .pyi #3011 - myby even caused by its fix?
- F821 "Undefined name" when variable is deleted in another branch #6242?
Version
ruff 0.15.2 (9d18ee9 2026-02-19)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working