Skip to content

Commit fb6386d

Browse files
committed
Properly calculate version of AnyIO
1 parent f3dd81c commit fb6386d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

asyncer/_compat.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# AnyIO 4.1.0 renamed cancellable to abandon_on_cancel
21
import sys
3-
from typing import Callable, TypeVar, Union
2+
from typing import Callable, Tuple, TypeVar, Union
43

54
import anyio
65
import anyio.to_thread
@@ -12,12 +11,16 @@
1211
else:
1312
from importlib.metadata import version as get_version
1413

15-
ANYIO_VERSION = get_version("anyio")
14+
ANYIO_VERSION: Tuple[int, ...] = tuple(
15+
int(num) for num in get_version("anyio").split(".")[:3]
16+
)
1617

1718
T_Retval = TypeVar("T_Retval")
1819
PosArgsT = TypeVarTuple("PosArgsT")
1920

20-
if ANYIO_VERSION >= "4.1.0":
21+
22+
# AnyIO 4.1.0 renamed cancellable to abandon_on_cancel
23+
if ANYIO_VERSION >= (4, 1):
2124

2225
async def run_sync(
2326
func: Callable[[Unpack[PosArgsT]], T_Retval],

0 commit comments

Comments
 (0)