Skip to content

Commit 2e969bd

Browse files
Copilotbinyamin555
andcommitted
Fix Python 3.7+ compatibility: use Union and Type instead of | and type
Co-authored-by: binyamin555 <42520501+binyamin555@users.noreply.github.com>
1 parent b545dd1 commit 2e969bd

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/extype/builtin_extensions/coroutine_ext.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from inspect import iscoroutine
2-
from typing import Awaitable, Callable, TypeVar
2+
from typing import Awaitable, Callable, Type, TypeVar, Union
33

44
from ..extension_utils import extend_type_with, extension
55

@@ -21,7 +21,7 @@ class CoroutineExtension:
2121
"""
2222

2323
@extension
24-
def then(self: Awaitable[_T], fn: Callable[[_T], Awaitable[_U] | _U]) -> Awaitable[_U]:
24+
def then(self: Awaitable[_T], fn: Callable[[_T], Union[Awaitable[_U], _U]]) -> Awaitable[_U]:
2525
"""
2626
Maps the result of the awaitable via an optionally async function.
2727
@@ -44,10 +44,10 @@ async def _then():
4444
@extension
4545
def catch(
4646
self: Awaitable[_T],
47-
fn: Callable[[_E], Awaitable[_U] | _U],
47+
fn: Callable[[_E], Union[Awaitable[_U], _U]],
4848
*,
49-
exception: type[_E] = Exception
50-
) -> Awaitable[_T | _U]:
49+
exception: Type[_E] = Exception
50+
) -> Awaitable[Union[_T, _U]]:
5151
"""
5252
Catches an exception of the given type and calls the passed function with the caught exception.
5353

0 commit comments

Comments
 (0)