Skip to content

typing-extensions not declared as dependency, breaks with Poetry 2.x on Python 3.12+ #37

@vgvoleg

Description

@vgvoleg

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions