From 1cfe1e4e1a65eb3e25c261a6a3e82f1677204203 Mon Sep 17 00:00:00 2001 From: Andrew Herrington Date: Tue, 7 May 2024 18:51:52 -0500 Subject: [PATCH] fix: adjust ci coverage and 3.12 support --- pydantic_aioredis/utils.py | 7 +++---- pyproject.toml | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pydantic_aioredis/utils.py b/pydantic_aioredis/utils.py index 8a5a740b..4fefc414 100644 --- a/pydantic_aioredis/utils.py +++ b/pydantic_aioredis/utils.py @@ -15,8 +15,6 @@ def bytes_to_string(data: bytes): class NestedAsyncIO: - """Patch asyncio to allow nested event loops.""" - __slots__ = [ "_loop", "orig_run", @@ -106,10 +104,11 @@ def _get_event_loop(stacklevel=3): asyncio.all_tasks = asyncio.tasks.Task.all_tasks elif sys.version_info >= (3, 9, 0): self.orig_get_loops = { - "events__get_event_loop": events._get_event_loop, "events_get_event_loop": events.get_event_loop, "asyncio_get_event_loop": asyncio.get_event_loop, } + if sys.version_info <= (3, 12, 0): + self.orig_get_loops["events__get_event_loop"] = (events._get_event_loop,) events._get_event_loop = events.get_event_loop = asyncio.get_event_loop = _get_event_loop self.orig_run = asyncio.run asyncio.run = run @@ -308,6 +307,6 @@ def patch_tornado(self): def unpatch_tornado(self): if self.orig_tc: - import tornado.concurrent as tc # noqa + import tornado.concurrent as tc tc.Future = self.orig_tc diff --git a/pyproject.toml b/pyproject.toml index d1fe94ed..19933298 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,8 +85,8 @@ build-backend = "poetry.core.masonry.api" exclude_dirs = ["test", "noxfile.py", ".github/scripts", "dist", "examples/*"] [tool.pytest.ini_options] -addopts = "-n 4 --ignore examples --cov=pydantic_aioredis --cov-report xml:.coverage.xml --cov-report=term-missing --cov-fail-under 91" +addopts = "-n 4 --ignore examples --cov=pydantic_aioredis --cov-report xml:.coverage.xml --cov-report=term-missing --cov-fail-under 85" [tool.ruff] line-length = 120 -target-version = "py37" +target-version = "py38"