From 2ec1b5725ebe54b524b59f2c0da541d34241afb5 Mon Sep 17 00:00:00 2001 From: Ivan Gonzalez Date: Sat, 22 Nov 2025 21:22:24 -0600 Subject: [PATCH] support Row type in row_factory and type connection attribute as well gh-15072 --- stdlib/sqlite3/__init__.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stdlib/sqlite3/__init__.pyi b/stdlib/sqlite3/__init__.pyi index 6b0f1ba94910..04b978b1b54c 100644 --- a/stdlib/sqlite3/__init__.pyi +++ b/stdlib/sqlite3/__init__.pyi @@ -222,6 +222,7 @@ _AdaptedInputData: TypeAlias = _SqliteData | Any _Parameters: TypeAlias = SupportsLenAndGetItem[_AdaptedInputData] | Mapping[str, _AdaptedInputData] # Controls the legacy transaction handling mode of sqlite3. _IsolationLevel: TypeAlias = Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | None +_RowFactoryOptions: TypeAlias = type[Row] | Callable[[Cursor, Row], object] | None @type_check_only class _AnyParamWindowAggregateClass(Protocol): @@ -300,7 +301,7 @@ class Connection: def autocommit(self) -> int: ... @autocommit.setter def autocommit(self, val: int) -> None: ... - row_factory: Any + row_factory: _RowFactoryOptions text_factory: Any if sys.version_info >= (3, 12): def __init__( @@ -416,7 +417,7 @@ class Cursor: def description(self) -> tuple[tuple[str, None, None, None, None, None, None], ...] | MaybeNone: ... @property def lastrowid(self) -> int | None: ... - row_factory: Callable[[Cursor, Row], object] | None + row_factory: _RowFactoryOptions @property def rowcount(self) -> int: ... def __init__(self, cursor: Connection, /) -> None: ...