[ty] Ensure annotation/type expressions in stub files are always deferred (#21401)

This commit is contained in:
Alex Waygood
2025-11-13 17:14:54 +00:00
committed by GitHub
parent 99694b6e4a
commit 90b32f3b3b
8 changed files with 115 additions and 5 deletions

View File

@@ -102,6 +102,20 @@ Other values are invalid.
P4 = ParamSpec("P4", default=int)
```
### Forward references in stub files
Stubs natively support forward references, so patterns that would raise `NameError` at runtime are
allowed in stub files:
```pyi
from typing_extensions import ParamSpec
P = ParamSpec("P", default=[A, B])
class A: ...
class B: ...
```
### PEP 695
```toml