From 8a3ba1163cdbe1e5fffd6b62b00d61925b8be200 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 23 Mar 2024 16:59:40 -0400 Subject: [PATCH] typing fix the most recent greenlet/asyncio commit introduced a typing error that only comes up under python3.10 due to the non-presence of asyncio.Runner in that version. do an intricate dance here along with another python-version-specific thing observed around the greenlet import. Change-Id: I1b220ab8ea633cdf43ad7e8abe826f758858b62a --- lib/sqlalchemy/util/_concurrency_py3k.py | 4 ++-- lib/sqlalchemy/util/concurrency.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sqlalchemy/util/_concurrency_py3k.py b/lib/sqlalchemy/util/_concurrency_py3k.py index defef1f6bf..5717d97061 100644 --- a/lib/sqlalchemy/util/_concurrency_py3k.py +++ b/lib/sqlalchemy/util/_concurrency_py3k.py @@ -243,11 +243,11 @@ def get_event_loop() -> asyncio.AbstractEventLoop: return asyncio.get_event_loop_policy().get_event_loop() -if py311: +if not TYPE_CHECKING and py311: _Runner = asyncio.Runner else: - class _Runner: # type: ignore[no-redef] + class _Runner: """Runner implementation for test only""" _loop: Union[None, asyncio.AbstractEventLoop, Literal[False]] diff --git a/lib/sqlalchemy/util/concurrency.py b/lib/sqlalchemy/util/concurrency.py index 96ba416cab..de6195de8f 100644 --- a/lib/sqlalchemy/util/concurrency.py +++ b/lib/sqlalchemy/util/concurrency.py @@ -18,7 +18,7 @@ from typing import TypeVar have_greenlet = False greenlet_error = None try: - import greenlet # type: ignore # noqa: F401 + import greenlet # type: ignore[import-untyped,unused-ignore] # noqa: F401,E501 except ImportError as e: greenlet_error = str(e) pass -- 2.47.2