From 87df3b984bd7cbd160a4eb73919a73a04e911985 Mon Sep 17 00:00:00 2001 From: Waket Zheng Date: Mon, 2 Sep 2024 12:19:12 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Python3.11+=20raises=20`Mo?= =?UTF-8?q?duleNotFoundError:=20No=20module=20named=20typing=5Fextensions`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- asyncer/_compat.py | 7 ++++++- asyncer/_main.py | 2 +- poetry.toml | 2 -- pyproject.toml | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) delete mode 100644 poetry.toml diff --git a/asyncer/_compat.py b/asyncer/_compat.py index ade175e8..687e9628 100644 --- a/asyncer/_compat.py +++ b/asyncer/_compat.py @@ -1,12 +1,17 @@ # AnyIO 4.1.0 renamed cancellable to abandon_on_cancel import importlib import importlib.metadata +import sys from typing import Callable, TypeVar, Union import anyio import anyio.to_thread from anyio import CapacityLimiter -from typing_extensions import TypeVarTuple, Unpack + +if sys.version_info >= (3, 11): + from typing import TypeVarTuple, Unpack +else: + from typing_extensions import TypeVarTuple, Unpack ANYIO_VERSION = importlib.metadata.version("anyio") diff --git a/asyncer/_main.py b/asyncer/_main.py index 78117e46..19d8318c 100644 --- a/asyncer/_main.py +++ b/asyncer/_main.py @@ -135,7 +135,7 @@ async def do_work(name: str) -> str: async with asyncer.create_task_group() as task_group: result1 = task_group.soonify(do_work)(name="task 1") result2 = task_group.soonify(do_work)(name="task 2") - await anyio.sleep(0) + await anyio.lowlevel.checkpoint() if not result1.pending: print(result1.value) if not result2.pending: diff --git a/poetry.toml b/poetry.toml deleted file mode 100644 index 084377a0..00000000 --- a/poetry.toml +++ /dev/null @@ -1,2 +0,0 @@ -[virtualenvs] -create = false diff --git a/pyproject.toml b/pyproject.toml index 3497d51d..82f6d791 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ classifiers = [ ] dependencies = [ "anyio >=3.4.0,<5.0", - "typing_extensions >=4.8.0; python_version < '3.10'" + "typing_extensions >=4.8.0; python_version < '3.11'" ] [project.urls]