Skip to content

Commit 0ba23bb

Browse files
committed
sqlite3: add 3.11 additions
- Blob from python/cpython#30680 (and anticipating that python/cpython#91550 will be merged) - Aggregate window functions from python/cpython#20903 - Serialize/deserialize from python/cpython#26728 - Limit setting from python/cpython#28463
1 parent 7f9be7f commit 0ba23bb

File tree

1 file changed

+45
-2
lines changed

1 file changed

+45
-2
lines changed

stdlib/sqlite3/dbapi2.pyi

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import sys
2-
from _typeshed import Self, StrOrBytesPath
2+
from _typeshed import ReadableBuffer, Self, StrOrBytesPath
33
from datetime import date, datetime, time
44
from types import TracebackType
5-
from typing import Any, Callable, Generator, Iterable, Iterator, Protocol, TypeVar
5+
from typing import Any, Callable, Generator, Iterable, Iterator, Protocol, TypeVar, overload
66
from typing_extensions import Literal, final
77

88
_T = TypeVar("_T")
9+
_SqliteData = str | bytes | int | float | None
910

1011
paramstyle: str
1112
threadsafety: int
@@ -128,6 +129,18 @@ class _AggregateProtocol(Protocol):
128129
def step(self, value: int) -> None: ...
129130
def finalize(self) -> int: ...
130131

132+
class _SingleParamWindowAggregateClass(Protocol):
133+
def step(self, __param: Any) -> None: ...
134+
def inverse(self, __param: Any) -> None: ...
135+
def value(self) -> _SqliteData: ...
136+
def finalize(self) -> _SqliteData: ...
137+
138+
class _WindowAggretateClass(Protocol):
139+
step: Callable[..., None]
140+
inverse: Callable[..., None]
141+
def value(self) -> _SqliteData: ...
142+
def finalize(self) -> _SqliteData: ...
143+
131144
class Connection:
132145
DataError: Any
133146
DatabaseError: Any
@@ -146,8 +159,23 @@ class Connection:
146159
total_changes: Any
147160
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
148161
def close(self) -> None: ...
162+
if sys.version_info >= (3, 11):
163+
def blobopen(self, __table: str, __column: str, __row: int, *, readonly: bool = ..., name: str = ...) -> Blob: ...
164+
149165
def commit(self) -> None: ...
150166
def create_aggregate(self, name: str, n_arg: int, aggregate_class: Callable[[], _AggregateProtocol]) -> None: ...
167+
if sys.version_info >= (3, 11):
168+
# num_params determines how many params will be passed to the aggregate class. We provide an overload
169+
# for the case where num_params = 1, which is expected to be the common case.
170+
@overload
171+
def create_window_function(
172+
self, __name: str, __num_params: Literal[1], aggregate_class: Callable[[], _SingleParamWindowAggregateClass]
173+
) -> None: ...
174+
@overload
175+
def create_window_function(
176+
self, __name: str, __num_params: int, aggregate_class: Callable[[], _WindowAggretateClass]
177+
) -> None: ...
178+
151179
def create_collation(self, __name: str, __callback: Any) -> None: ...
152180
if sys.version_info >= (3, 8):
153181
def create_function(self, name: str, narg: int, func: Any, *, deterministic: bool = ...) -> None: ...
@@ -181,6 +209,11 @@ class Connection:
181209
name: str = ...,
182210
sleep: float = ...,
183211
) -> None: ...
212+
if sys.version_info >= (3, 11):
213+
def setlimit(self, __category: int, __limit: int) -> int: ...
214+
def getlimit(self, __category: int) -> int: ...
215+
def serialize(self, *, name: str = ...) -> bytes: ...
216+
def deserialize(self, __data: ReadableBuffer, *, name: str = ...) -> None: ...
184217

185218
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
186219
def __enter__(self: Self) -> Self: ...
@@ -253,3 +286,13 @@ if sys.version_info < (3, 8):
253286
def __init__(self, *args, **kwargs): ...
254287

255288
class Warning(Exception): ...
289+
290+
if sys.version_info >= (3, 11):
291+
class Blob:
292+
def close(self) -> None: ...
293+
def read(self, __length: int = ...) -> bytes: ...
294+
def write(self, __data: bytes) -> None: ...
295+
def tell(self) -> int: ...
296+
# whence must be one of os.SEEK_SET, os.SEEK_CUR, os.SEEK_END
297+
def seek(self, __offset: int, __whence: int = ...) -> None: ...
298+
def __len__(self) -> int: ...

0 commit comments

Comments
 (0)