Skip to content

Commit

Permalink
fix: rm AnyAwaitable
Browse files Browse the repository at this point in the history
  • Loading branch information
phi-friday committed Aug 7, 2024
1 parent 7cc6137 commit 1fc5b33
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
9 changes: 4 additions & 5 deletions src/timeout_executor/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import anyio
import cloudpickle
from typing_extensions import ParamSpec, Self, TypeAlias, TypeVar, override
from typing_extensions import ParamSpec, Self, TypeVar, override

from timeout_executor.const import SUBPROCESS_COMMAND, TIMEOUT_EXECUTOR_INPUT_FILE
from timeout_executor.logging import logger
Expand All @@ -24,7 +24,7 @@
from timeout_executor.types import Callback, CallbackArgs, ExecutorArgs, ProcessCallback

if TYPE_CHECKING:
from collections.abc import Awaitable, Coroutine, Iterable
from collections.abc import Awaitable, Iterable

from timeout_executor.main import TimeoutExecutor

Expand All @@ -34,7 +34,6 @@
T = TypeVar("T", infer_variance=True)
P2 = ParamSpec("P2")
T2 = TypeVar("T2", infer_variance=True)
AnyAwaitable: TypeAlias = "Awaitable[T] | Coroutine[Any, Any, T]"


class Executor(Callback[P, T], Generic[P, T]):
Expand Down Expand Up @@ -202,7 +201,7 @@ def remove_callback(self, callback: ProcessCallback[P, T]) -> Self:
@overload
def apply_func(
timeout_or_executor: float | TimeoutExecutor,
func: Callable[P2, AnyAwaitable[T2]],
func: Callable[P2, Awaitable[T2]],
*args: P2.args,
**kwargs: P2.kwargs,
) -> AsyncResult[P2, T2]: ...
Expand Down Expand Up @@ -246,7 +245,7 @@ def apply_func(
@overload
async def delay_func(
timeout_or_executor: float | TimeoutExecutor,
func: Callable[P2, AnyAwaitable[T2]],
func: Callable[P2, Awaitable[T2]],
*args: P2.args,
**kwargs: P2.kwargs,
) -> AsyncResult[P2, T2]: ...
Expand Down
11 changes: 5 additions & 6 deletions src/timeout_executor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from contextlib import suppress
from typing import TYPE_CHECKING, Any, Callable, Generic, overload

from typing_extensions import ParamSpec, Self, TypeAlias, TypeVar, override
from typing_extensions import ParamSpec, Self, TypeVar, override

from timeout_executor.executor import apply_func, delay_func
from timeout_executor.types import Callback, ProcessCallback

if TYPE_CHECKING:
from collections.abc import Awaitable, Coroutine, Iterable
from collections.abc import Awaitable, Iterable

from timeout_executor.result import AsyncResult

Expand All @@ -19,7 +19,6 @@
P = ParamSpec("P")
T = TypeVar("T", infer_variance=True)
AnyT = TypeVar("AnyT", infer_variance=True, default=Any)
AnyAwaitable: TypeAlias = "Awaitable[T] | Coroutine[Any, Any, T]"


class TimeoutExecutor(Callback[Any, AnyT], Generic[AnyT]):
Expand All @@ -36,7 +35,7 @@ def timeout(self) -> float:

@overload
def apply(
self, func: Callable[P, AnyAwaitable[T]], *args: P.args, **kwargs: P.kwargs
self, func: Callable[P, Awaitable[T]], *args: P.args, **kwargs: P.kwargs
) -> AsyncResult[P, T]: ...
@overload
def apply(
Expand All @@ -59,7 +58,7 @@ def apply(

@overload
async def delay(
self, func: Callable[P, AnyAwaitable[T]], *args: P.args, **kwargs: P.kwargs
self, func: Callable[P, Awaitable[T]], *args: P.args, **kwargs: P.kwargs
) -> AsyncResult[P, T]: ...
@overload
async def delay(
Expand All @@ -82,7 +81,7 @@ async def delay(

@overload
async def apply_async(
self, func: Callable[P, AnyAwaitable[T]], *args: P.args, **kwargs: P.kwargs
self, func: Callable[P, Awaitable[T]], *args: P.args, **kwargs: P.kwargs
) -> AsyncResult[P, T]: ...
@overload
async def apply_async(
Expand Down
5 changes: 2 additions & 3 deletions src/timeout_executor/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from collections.abc import Awaitable, Coroutine
from collections.abc import Awaitable
from os import environ
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable
Expand All @@ -12,11 +12,10 @@
from timeout_executor.const import TIMEOUT_EXECUTOR_INPUT_FILE

if TYPE_CHECKING:
from typing_extensions import ParamSpec, TypeAlias, TypeVar
from typing_extensions import ParamSpec, TypeVar

P = ParamSpec("P")
T = TypeVar("T", infer_variance=True)
AnyAwaitable: TypeAlias = "Awaitable[T] | Coroutine[Any, Any, T]"

__all__ = []

Expand Down

0 comments on commit 1fc5b33

Please sign in to comment.