-
Notifications
You must be signed in to change notification settings - Fork 135
Closed
astral-sh/ruff
#20479Labels
bugSomething isn't workingSomething isn't workinggenericsBugs or features relating to ty's generics implementationBugs or features relating to ty's generics implementation
Description
The following example …
from typing import Callable
def invoke[A, B](fn: Callable[[A], B], value: A) -> B:
return fn(value)
def identity[T](x: T) -> T:
return x
invoke(identity, 1)(https://play.ty.dev/6dfb9951-b78f-4791-af82-151a1c694a7c)
… currently fails with this error:
error[invalid-argument-type]: Argument to function `invoke` is incorrect
--> /home/shark/playground/test.py:12:8
|
12 | invoke(identity, 1)
| ^^^^^^^^ Expected `(Literal[1], /) -> Unknown`, found `def identity[T](x: T@identity) -> T@identity`
|
info: Function defined here
--> /home/shark/playground/test.py:4:5
|
4 | def invoke[A, B](fn: Callable[[A], B], value: A) -> B:
| ^^^^^^ -------------------- Parameter declared here
5 | return fn(value)
|
info: rule `invalid-argument-type` is enabled by default
I am reporting this in addition to #623, because it seems like this is not really related to the shortcomings of the current solver, but rather to the way we handle assignability of the generic identity function argument to the call(?).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggenericsBugs or features relating to ty's generics implementationBugs or features relating to ty's generics implementation