[PR #3670] chore(langgraph): fix typing of task decorator #3417

Closed
opened 2026-02-20 17:48:34 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/3670

State: closed
Merged: Yes


An async function of the form def foo(P) -> T has type Callable[[P], Awaitable[T]]. The old type annotations then converted the function into a Callable[[P], SyncAsyncFuture[Awaitable[T]]] which is incorrect.

The change introduced in this commit updates the type annotations to ensure the Awaitable[T] is correctly unwrapped.

I've tested it locally and confirmed it work on:

@task 
def sync_fn(a: int) -> int: ...

@task 
def async_fn(a: int) -> int: ...

Let me know if you want me to add tests, just let me know how you test type annotations.

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/3670 **State:** closed **Merged:** Yes --- An async function of the form `def foo(P) -> T` has type `Callable[[P], Awaitable[T]]`. The old type annotations then converted the function into a `Callable[[P], SyncAsyncFuture[Awaitable[T]]]` which is incorrect. The change introduced in this commit updates the type annotations to ensure the `Awaitable[T]` is correctly unwrapped. I've tested it locally and confirmed it work on: ```python @task def sync_fn(a: int) -> int: ... @task def async_fn(a: int) -> int: ... ``` Let me know if you want me to add tests, just let me know how you test type annotations.
yindo added the pull-request label 2026-02-20 17:48:34 -05:00
yindo closed this issue 2026-02-20 17:48:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#3417