Skip to content

future() and future_safe() overly restrictive type signatures #2404

Description

@bvolkmer

Bug report

What's wrong

The functions future() and future_save() use Coroutine as parameter types, where Awaitable would be enough.

How is that should be

Use Awaitable as parameter type.

Example failing in type checker but not at execution time

def untap_async[**P](a: Callable[P, Awaitable[object]]) -> Callable[P, Awaitable[None]]:
    async def inner(*args: P.args, **kwargs: P.kwargs) -> None:
        await a(*args, **kwargs)

    return inner


async def foo(): ...

future(untap_async())

System information

  • python version: 3.14.2
  • returns version: 0.27.0
  • pyrefly version: 0.64.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions