Skip to content

Commit f02cd37

Browse files
committed
Fix types
1 parent 8a9a7b4 commit f02cd37

File tree

1 file changed

+12
-2
lines changed
  • reportportal_client/_internal/aio

1 file changed

+12
-2
lines changed

reportportal_client/_internal/aio/tasks.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,21 @@
2121

2222
from reportportal_client.aio.tasks import BlockingOperationError, Task
2323

24+
if sys.version_info >= (3, 10):
25+
from typing import TypeAlias
26+
else:
27+
from typing_extensions import TypeAlias
28+
2429
_T = TypeVar("_T")
2530

2631
DEFAULT_TASK_TRIGGER_NUM: int = 10
2732
DEFAULT_TASK_TRIGGER_INTERVAL: float = 1.0
2833

34+
if sys.version_info >= (3, 12):
35+
_TaskCompatibleCoro: TypeAlias = Coroutine[Any, Any, Any]
36+
else:
37+
_TaskCompatibleCoro: TypeAlias = Union[Generator[Optional[Future[object]], None, Any], Coroutine[Any, Any, Any]]
38+
2939

3040
class BatchedTask(Generic[_T], Task[_T]):
3141
"""Represents a Task which uses the current Thread to execute itself."""
@@ -34,7 +44,7 @@ class BatchedTask(Generic[_T], Task[_T]):
3444

3545
def __init__(
3646
self,
37-
coro: Union[Generator[Optional[Future[object]], None, Any], Coroutine[Any, Any, Any]],
47+
coro: _TaskCompatibleCoro,
3848
*,
3949
loop: asyncio.AbstractEventLoop,
4050
name: Optional[str] = None,
@@ -68,7 +78,7 @@ class ThreadedTask(Generic[_T], Task[_T]):
6878

6979
def __init__(
7080
self,
71-
coro: Union[Generator[Optional[Future[object]], None, Any], Coroutine[Any, Any, Any]],
81+
coro: _TaskCompatibleCoro,
7282
wait_timeout: float,
7383
*,
7484
loop: asyncio.AbstractEventLoop,

0 commit comments

Comments
 (0)