[ty] Improve disambiguation of types via fully qualified names (#20141)

This commit is contained in:
Alex Waygood
2025-08-29 09:44:18 +01:00
committed by GitHub
parent 0d7ed32494
commit 04dc223710
4 changed files with 183 additions and 88 deletions

View File

@@ -260,6 +260,11 @@ def f(cond: bool) -> int:
<!-- snapshot-diagnostics -->
```toml
[environment]
python-version = "3.12"
```
```py
# error: [invalid-return-type]
def f() -> int:
@@ -279,6 +284,18 @@ T = TypeVar("T")
# error: [invalid-return-type]
def m(x: T) -> T: ...
class A[T]: ...
def f() -> A[int]:
class A[T]: ...
return A[int]() # error: [invalid-return-type]
class B: ...
def g() -> B:
class B: ...
return B() # error: [invalid-return-type]
```
## Invalid return type in stub file