11import sys
2- from _typeshed import Self , StrOrBytesPath
2+ from _typeshed import ReadableBuffer , Self , StrOrBytesPath
33from datetime import date , datetime , time
44from 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
66from typing_extensions import Literal , final
77
88_T = TypeVar ("_T" )
9+ _SqliteData = str | bytes | int | float | None
910
1011paramstyle : str
1112threadsafety : int
@@ -125,9 +126,27 @@ if sys.version_info < (3, 8):
125126 def get (self , * args , ** kwargs ) -> None : ...
126127
127128class _AggregateProtocol (Protocol ):
128- def step (self , value : int ) -> None : ...
129+ def step (self , value : int ) -> object : ...
129130 def finalize (self ) -> int : ...
130131
132+ class _SingleParamWindowAggregateClass (Protocol ):
133+ def step (self , __param : Any ) -> object : ...
134+ def inverse (self , __param : Any ) -> object : ...
135+ def value (self ) -> _SqliteData : ...
136+ def finalize (self ) -> _SqliteData : ...
137+
138+ class _AnyParamWindowAggregateClass (Protocol ):
139+ def step (self , * args : Any ) -> object : ...
140+ def inverse (self , * args : Any ) -> object : ...
141+ def value (self ) -> _SqliteData : ...
142+ def finalize (self ) -> _SqliteData : ...
143+
144+ class _WindowAggregateClass (Protocol ):
145+ step : Callable [..., object ]
146+ inverse : Callable [..., object ]
147+ def value (self ) -> _SqliteData : ...
148+ def finalize (self ) -> _SqliteData : ...
149+
131150class Connection :
132151 DataError : Any
133152 DatabaseError : Any
@@ -146,8 +165,28 @@ class Connection:
146165 total_changes : Any
147166 def __init__ (self , * args : Any , ** kwargs : Any ) -> None : ...
148167 def close (self ) -> None : ...
168+ if sys .version_info >= (3 , 11 ):
169+ def blobopen (self , __table : str , __column : str , __row : int , * , readonly : bool = ..., name : str = ...) -> Blob : ...
170+
149171 def commit (self ) -> None : ...
150172 def create_aggregate (self , name : str , n_arg : int , aggregate_class : Callable [[], _AggregateProtocol ]) -> None : ...
173+ if sys .version_info >= (3 , 11 ):
174+ # num_params determines how many params will be passed to the aggregate class. We provide an overload
175+ # for the case where num_params = 1, which is expected to be the common case.
176+ @overload
177+ def create_window_function (
178+ self , __name : str , __num_params : Literal [1 ], __aggregate_class : Callable [[], _SingleParamWindowAggregateClass ] | None
179+ ) -> None : ...
180+ # And for num_params = -1, which means the aggregate must accept any number of parameters.
181+ @overload
182+ def create_window_function (
183+ self , __name : str , __num_params : Literal [- 1 ], __aggregate_class : Callable [[], _AnyParamWindowAggregateClass ] | None
184+ ) -> None : ...
185+ @overload
186+ def create_window_function (
187+ self , __name : str , __num_params : int , __aggregate_class : Callable [[], _WindowAggregateClass ] | None
188+ ) -> None : ...
189+
151190 def create_collation (self , __name : str , __callback : Any ) -> None : ...
152191 if sys .version_info >= (3 , 8 ):
153192 def create_function (self , name : str , narg : int , func : Any , * , deterministic : bool = ...) -> None : ...
@@ -181,6 +220,11 @@ class Connection:
181220 name : str = ...,
182221 sleep : float = ...,
183222 ) -> None : ...
223+ if sys .version_info >= (3 , 11 ):
224+ def setlimit (self , __category : int , __limit : int ) -> int : ...
225+ def getlimit (self , __category : int ) -> int : ...
226+ def serialize (self , * , name : str = ...) -> bytes : ...
227+ def deserialize (self , __data : ReadableBuffer , * , name : str = ...) -> None : ...
184228
185229 def __call__ (self , * args : Any , ** kwargs : Any ) -> Any : ...
186230 def __enter__ (self : Self ) -> Self : ...
@@ -253,3 +297,15 @@ if sys.version_info < (3, 8):
253297 def __init__ (self , * args , ** kwargs ): ...
254298
255299class Warning (Exception ): ...
300+
301+ if sys .version_info >= (3 , 11 ):
302+ class Blob :
303+ def close (self ) -> None : ...
304+ def read (self , __length : int = ...) -> bytes : ...
305+ def write (self , __data : bytes ) -> None : ...
306+ def tell (self ) -> int : ...
307+ # whence must be one of os.SEEK_SET, os.SEEK_CUR, os.SEEK_END
308+ def seek (self , __offset : int , __whence : int = ...) -> None : ...
309+ def __len__ (self ) -> int : ...
310+ def __enter__ (self : Self ) -> Self : ...
311+ def __exit__ (self , __typ : object , __val : object , __tb : object ) -> Literal [False ]: ...
0 commit comments