mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-17 13:57:25 +00:00
[ty] Improve disambiguation of types via fully qualified names (#20141)
This commit is contained in:
parent
0d7ed32494
commit
04dc223710
4 changed files with 183 additions and 88 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue