diff --git a/src/helpers/timeout/_helper.py b/src/helpers/timeout/_helper.py index 7ba9c652d3..56c7e9dace 100644 --- a/src/helpers/timeout/_helper.py +++ b/src/helpers/timeout/_helper.py @@ -1,5 +1,5 @@ from __future__ import annotations -from typing import Callable, Optional, Awaitable, Generic, TypeVar, Any +from typing import Callable, Optional, Awaitable, Generic, TypeVar, Any, Union from typing_extensions import ParamSpec import asyncio @@ -20,10 +20,10 @@ def __init__( timeout: float, loop: asyncio.AbstractEventLoop = None, on_success: Callable[[R, P], None] = noop, - on_canceled: Callable[[BaseException, P], None] = noop, - on_error: Callable[[BaseException, P], None] = noop, - on_timeout: Callable[[BaseException, P], None] = noop, - on_timeout_error: Callable[[BaseException, P], None] = noop, + on_canceled: Callable[[asyncio.CancelledError, P], None] = noop, + on_error: Callable[[Exception, P], None] = noop, + on_timeout: Callable[[asyncio.CancelledError, P], None] = noop, + on_timeout_error: Callable[[Union[asyncio.CancelledError, Exception], P], None] = noop, ): """ A context manager aims to solve these issues: