Skip to content

Commit 2c92b81

Browse files
committed
fix: Fix removed type annotation
1 parent 2224c51 commit 2c92b81

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

hoyo_buddy/utils/startup.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
from __future__ import annotations
2+
13
import asyncio
24
import sys
3-
from typing import Any
5+
from typing import TYPE_CHECKING, Any
46

57
import sentry_sdk
68
from loguru import logger
@@ -12,6 +14,9 @@
1214
from hoyo_buddy.config import CONFIG
1315
from hoyo_buddy.utils.misc import get_project_version, should_ignore_error
1416

17+
if TYPE_CHECKING:
18+
from collections.abc import Coroutine
19+
1520
__all__ = ("setup_async_event_loop", "setup_sentry", "wrap_task_factory")
1621

1722
_tasks_set: set[asyncio.Task[Any] | asyncio.Future[Any]] = set()
@@ -21,7 +26,7 @@ def wrap_task_factory() -> None:
2126
loop = asyncio.get_running_loop()
2227
original_factory = loop.get_task_factory()
2328

24-
async def coro_wrapper(coro: asyncio._CoroutineLike[Any], coro_name: str | None = None) -> Any:
29+
async def coro_wrapper(coro: Coroutine[Any, Any, Any], coro_name: str | None = None) -> Any:
2530
try:
2631
return await coro
2732
except Exception as e:
@@ -37,7 +42,7 @@ async def coro_wrapper(coro: asyncio._CoroutineLike[Any], coro_name: str | None
3742
raise
3843

3944
def new_factory(
40-
loop: asyncio.AbstractEventLoop, coro: asyncio._CoroutineLike[Any], **kwargs
45+
loop: asyncio.AbstractEventLoop, coro: Coroutine[Any, Any, Any], **kwargs
4146
) -> asyncio.Task[Any] | asyncio.Future[Any]:
4247
wrapped_coro = coro_wrapper(coro, coro_name=kwargs.get("name"))
4348

0 commit comments

Comments
 (0)