[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:
David Peter 2025-04-28 16:40:35 +02:00 committed by GitHub
parent 1e8881f9af
commit 07718f4788
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View File

@ -225,14 +225,16 @@ Using `Concatenate` as the first argument to `Callable`:
from typing_extensions import Callable, Concatenate from typing_extensions import Callable, Concatenate
def _(c: Callable[Concatenate[int, str, ...], int]): 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: And, as one of the parameter types:
```py ```py
def _(c: Callable[[Concatenate[int, str, ...], int], int]): 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` ## Using `typing.ParamSpec`
@ -276,7 +278,8 @@ from typing_extensions import Callable, TypeVarTuple
Ts = TypeVarTuple("Ts") Ts = TypeVarTuple("Ts")
def _(c: Callable[[int, *Ts], int]): 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`: And, using the legacy syntax using `Unpack`:
@ -285,7 +288,8 @@ And, using the legacy syntax using `Unpack`:
from typing_extensions import Unpack from typing_extensions import Unpack
def _(c: Callable[[int, Unpack[Ts]], int]): 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 ## Member lookup

View File

@ -895,7 +895,7 @@ impl<'db> Parameters<'db> {
Parameter::keyword_variadic(Name::new_static("kwargs")) Parameter::keyword_variadic(Name::new_static("kwargs"))
.with_annotated_type(todo_type!("todo signature **kwargs")), .with_annotated_type(todo_type!("todo signature **kwargs")),
], ],
is_gradual: false, is_gradual: true,
} }
} }