Bug
ydb_dbapi/cursors.py unconditionally imports from typing_extensions:
from typing_extensions import Self
However, typing-extensions is not declared as a dependency in pyproject.toml. This works with Poetry 1.x (which installs typing-extensions unconditionally as a transitive dep), but fails with Poetry 2.x on Python 3.12+.
With Poetry 2.x, the dependency marker for typing-extensions is computed as python_version < "3.11" (since all other packages that declare it only need it on older Python). As a result, typing-extensions is not installed on Python 3.12/3.13, and importing ydb_dbapi raises:
ModuleNotFoundError: No module named 'typing_extensions'
Root cause
typing-extensions is not listed in [tool.poetry.dependencies], so Poetry 2.x does not install it on Python 3.11+.
Fix
Either:
A. Declare it as an explicit dependency:
typing-extensions = ">=4.0"
B. Fix the import in cursors.py to use stdlib on Python 3.11+ and declare it as a conditional dependency:
import sys
if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self
typing-extensions = {version = ">=4.0", python = "<3.11"}
Discovered in
django-ydb-backend while adding a Django version CI matrix (Poetry 2.x, Python 3.12).
Bug
ydb_dbapi/cursors.pyunconditionally imports fromtyping_extensions:However,
typing-extensionsis not declared as a dependency inpyproject.toml. This works with Poetry 1.x (which installstyping-extensionsunconditionally as a transitive dep), but fails with Poetry 2.x on Python 3.12+.With Poetry 2.x, the dependency marker for
typing-extensionsis computed aspython_version < "3.11"(since all other packages that declare it only need it on older Python). As a result,typing-extensionsis not installed on Python 3.12/3.13, and importingydb_dbapiraises:Root cause
typing-extensionsis not listed in[tool.poetry.dependencies], so Poetry 2.x does not install it on Python 3.11+.Fix
Either:
A. Declare it as an explicit dependency:
B. Fix the import in
cursors.pyto use stdlib on Python 3.11+ and declare it as a conditional dependency:Discovered in
django-ydb-backend while adding a Django version CI matrix (Poetry 2.x, Python 3.12).