mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
[red-knot] Allow all callables to be assignable to @Todo-signatures (#17680)
## Summary Removes ~850 diagnostics related to assignability of callable types, where the callable-being-assigned-to has a "Todo signature", which should probably accept any left hand side callable/signature.
This commit is contained in:
parent
1e8881f9af
commit
07718f4788
2 changed files with 9 additions and 5 deletions
|
@ -225,14 +225,16 @@ Using `Concatenate` as the first argument to `Callable`:
|
|||
from typing_extensions import Callable, Concatenate
|
||||
|
||||
def _(c: Callable[Concatenate[int, str, ...], int]):
|
||||
reveal_type(c) # revealed: (*args: @Todo(todo signature *args), **kwargs: @Todo(todo signature **kwargs)) -> int
|
||||
# TODO: Should reveal the correct signature
|
||||
reveal_type(c) # revealed: (...) -> int
|
||||
```
|
||||
|
||||
And, as one of the parameter types:
|
||||
|
||||
```py
|
||||
def _(c: Callable[[Concatenate[int, str, ...], int], int]):
|
||||
reveal_type(c) # revealed: (*args: @Todo(todo signature *args), **kwargs: @Todo(todo signature **kwargs)) -> int
|
||||
# TODO: Should reveal the correct signature
|
||||
reveal_type(c) # revealed: (...) -> int
|
||||
```
|
||||
|
||||
## Using `typing.ParamSpec`
|
||||
|
@ -276,7 +278,8 @@ from typing_extensions import Callable, TypeVarTuple
|
|||
Ts = TypeVarTuple("Ts")
|
||||
|
||||
def _(c: Callable[[int, *Ts], int]):
|
||||
reveal_type(c) # revealed: (*args: @Todo(todo signature *args), **kwargs: @Todo(todo signature **kwargs)) -> int
|
||||
# TODO: Should reveal the correct signature
|
||||
reveal_type(c) # revealed: (...) -> int
|
||||
```
|
||||
|
||||
And, using the legacy syntax using `Unpack`:
|
||||
|
@ -285,7 +288,8 @@ And, using the legacy syntax using `Unpack`:
|
|||
from typing_extensions import Unpack
|
||||
|
||||
def _(c: Callable[[int, Unpack[Ts]], int]):
|
||||
reveal_type(c) # revealed: (*args: @Todo(todo signature *args), **kwargs: @Todo(todo signature **kwargs)) -> int
|
||||
# TODO: Should reveal the correct signature
|
||||
reveal_type(c) # revealed: (...) -> int
|
||||
```
|
||||
|
||||
## Member lookup
|
||||
|
|
|
@ -895,7 +895,7 @@ impl<'db> Parameters<'db> {
|
|||
Parameter::keyword_variadic(Name::new_static("kwargs"))
|
||||
.with_annotated_type(todo_type!("todo signature **kwargs")),
|
||||
],
|
||||
is_gradual: false,
|
||||
is_gradual: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue