Model SQLAlchemy 2.0 and 2.1 in the base-install test

This commit is contained in:
2026-10-01 20:53:34 -06:00
parent 4995143f8f
commit 76999c942c
+8 -1
View File
@@ -6,8 +6,15 @@ the ``instrumentation`` extra. Argument: a directory for the feedback database.
"""
import sys
from importlib.metadata import version
for _name in ("greenlet", "aiosqlite"):
# SQLAlchemy 2.1 refuses to import sqlalchemy.ext.asyncio without greenlet,
# once: a second import succeeds. 2.0 imports it and fails on first use.
# On 2.0 the module is blocked too, so both versions fail at import.
_blocked = ["greenlet", "aiosqlite"]
if tuple(int(p) for p in version("sqlalchemy").split(".")[:2]) < (2, 1):
_blocked.append("sqlalchemy.ext.asyncio")
for _name in _blocked:
sys.modules[_name] = None # import raises ModuleNotFoundError
import asyncio # noqa: E402