-
Notifications
You must be signed in to change notification settings - Fork 216
Closed
astral-sh/ruff
#21946Labels
bugSomething isn't workingSomething isn't workingcallsIssues relating to call-signature checking and diagnosticsIssues relating to call-signature checking and diagnosticsoverloads
Milestone
Description
Summary
Upgraded from 0.0.1a26 to 0.0.1a33 and noticed issues with asyncio.to_thread in combination with overloaded functions. Initially noticed with open but can be reduced to some simple example:
import asyncio
from typing import overload
def normal(a: str) -> None:
pass
@overload
def overloaded(a: str) -> None:
pass
@overload
def overloaded(a: int) -> None:
pass
def overloaded(a: str | int) -> None:
pass
t1 = normal("test")
t2 = overloaded("test")
t3 = asyncio.to_thread(normal, "test")
t4 = asyncio.to_thread(overloaded, "test")
ty check gives:
error[invalid-argument-type]: Argument to function `to_thread` is incorrect
--> test.py:26:36
|
24 | t2 = overloaded("test")
25 | t3 = asyncio.to_thread(normal, "test")
26 | t4 = asyncio.to_thread(overloaded, "test")
| ^^^^^^ Expected `Overload[(a: str) -> Unknown, (a: int) -> Unknown]`, found `Literal["test"]`
|
info: Function defined here
--> stdlib/asyncio/threads.pyi:12:11
|
10 | _R = TypeVar("_R")
11 |
12 | async def to_thread(func: Callable[_P, _R], /, *args: _P.args, **kwargs: _P.kwargs) -> _R:
| ^^^^^^^^^ -------------- Parameter declared here
13 | """Asynchronously run function *func* in a separate thread.
|
info: rule `invalid-argument-type` is enabled by default
Version
ty 0.0.1a33
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcallsIssues relating to call-signature checking and diagnosticsIssues relating to call-signature checking and diagnosticsoverloads