Skip to content

Commit

Permalink
[typing] Remove overload from inject_client
Browse files Browse the repository at this point in the history
The decorator can't accept a regular callable (it uses `await` when
calling the wrapped function), and has so far never been used on
anything but coroutines.
  • Loading branch information
mjpieters committed Dec 19, 2024
1 parent 26041af commit b341f27
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/prefect/client/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from collections.abc import Awaitable, Coroutine
from functools import wraps
from typing import TYPE_CHECKING, Any, Callable, Optional, Union, overload
from typing import TYPE_CHECKING, Any, Callable, Optional, Union

from typing_extensions import Concatenate, ParamSpec, TypeGuard, TypeVar

Expand Down Expand Up @@ -71,23 +71,9 @@ async def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
return wrapper


@overload
def inject_client(
fn: Callable[P, Coroutine[Any, Any, R]],
) -> Callable[P, Coroutine[Any, Any, R]]:
...


@overload
def inject_client(
fn: Callable[P, R],
) -> Callable[P, R]:
...


def inject_client(
fn: Callable[P, Union[Coroutine[Any, Any, R], R]],
) -> Callable[P, Union[Coroutine[Any, Any, R], R]]:
"""
Simple helper to provide a context managed client to an asynchronous function.
Expand Down

0 comments on commit b341f27

Please sign in to comment.