@@ -216,6 +216,7 @@ if sys.version_info < (3, 10):
216216
217217_CursorT = TypeVar ("_CursorT" , bound = Cursor )
218218_SqliteData : TypeAlias = str | ReadableBuffer | int | float | None
219+ _SQLType = TypeVar ("_SQLType" , bound = _SqliteData )
219220# Data that is passed through adapters can be of any type accepted by an adapter.
220221_AdaptedInputData : TypeAlias = _SqliteData | Any
221222# The Mapping must really be a dict, but making it invariant is too annoying.
@@ -225,28 +226,29 @@ _IsolationLevel: TypeAlias = Literal["DEFERRED", "EXCLUSIVE", "IMMEDIATE"] | Non
225226_RowFactoryOptions : TypeAlias = type [Row ] | Callable [[Cursor , Row ], object ] | None
226227
227228@type_check_only
228- class _AnyParamWindowAggregateClass (Protocol ):
229- def step (self , * args : Any ) -> object : ...
230- def inverse (self , * args : Any ) -> object : ...
231- def value (self ) -> _SqliteData : ...
232- def finalize (self ) -> _SqliteData : ...
229+ class _SingleParamAggregateProtocol (Protocol [_SQLType ]):
230+ def step (self , param : _SQLType , / ) -> object : ...
231+ def finalize (self ) -> _SQLType : ...
233232
234233@type_check_only
235- class _WindowAggregateClass (Protocol ):
236- step : Callable [..., object ]
237- inverse : Callable [..., object ]
238- def value (self ) -> _SqliteData : ...
234+ class _AnyParamAggregateProtocol (Protocol ):
235+ @property
236+ def step (self ) -> Callable [..., object ]: ...
239237 def finalize (self ) -> _SqliteData : ...
240238
241239@type_check_only
242- class _AggregateProtocol (Protocol ):
243- def step (self , value : int , / ) -> object : ...
244- def finalize (self ) -> int : ...
240+ class _SingleParamWindowAggregateClass (Protocol [_SQLType ]):
241+ def step (self , param : _SQLType , / ) -> object : ...
242+ def inverse (self , param : _SQLType , / ) -> object : ...
243+ def value (self ) -> _SQLType : ...
244+ def finalize (self ) -> _SQLType : ...
245245
246246@type_check_only
247- class _SingleParamWindowAggregateClass (Protocol ):
248- def step (self , param : Any , / ) -> object : ...
249- def inverse (self , param : Any , / ) -> object : ...
247+ class _AnyParamWindowAggregateClass (Protocol ):
248+ @property
249+ def step (self ) -> Callable [..., object ]: ...
250+ @property
251+ def inverse (self ) -> Callable [..., object ]: ...
250252 def value (self ) -> _SqliteData : ...
251253 def finalize (self ) -> _SqliteData : ...
252254
@@ -334,22 +336,27 @@ class Connection:
334336 def blobopen (self , table : str , column : str , row : int , / , * , readonly : bool = False , name : str = "main" ) -> Blob : ...
335337
336338 def commit (self ) -> None : ...
337- def create_aggregate (self , name : str , n_arg : int , aggregate_class : Callable [[], _AggregateProtocol ]) -> None : ...
339+ @overload
340+ def create_aggregate (
341+ self , name : str , n_arg : Literal [1 ], aggregate_class : Callable [[], _SingleParamAggregateProtocol [_SQLType ]]
342+ ) -> None : ...
343+ @overload
344+ def create_aggregate (self , name : str , n_arg : int , aggregate_class : Callable [[], _AnyParamAggregateProtocol ]) -> None : ...
345+
338346 if sys .version_info >= (3 , 11 ):
339347 # num_params determines how many params will be passed to the aggregate class. We provide an overload
340348 # for the case where num_params = 1, which is expected to be the common case.
341349 @overload
342350 def create_window_function (
343- self , name : str , num_params : Literal [1 ], aggregate_class : Callable [[], _SingleParamWindowAggregateClass ] | None , /
344- ) -> None : ...
345- # And for num_params = -1, which means the aggregate must accept any number of parameters.
346- @overload
347- def create_window_function (
348- self , name : str , num_params : Literal [- 1 ], aggregate_class : Callable [[], _AnyParamWindowAggregateClass ] | None , /
351+ self ,
352+ name : str ,
353+ num_params : Literal [1 ],
354+ aggregate_class : Callable [[], _SingleParamWindowAggregateClass [_SQLType ]] | None ,
355+ / ,
349356 ) -> None : ...
350357 @overload
351358 def create_window_function (
352- self , name : str , num_params : int , aggregate_class : Callable [[], _WindowAggregateClass ] | None , /
359+ self , name : str , num_params : int , aggregate_class : Callable [[], _AnyParamWindowAggregateClass ] | None , /
353360 ) -> None : ...
354361
355362 def create_collation (self , name : str , callback : Callable [[str , str ], int | SupportsIndex ] | None , / ) -> None : ...
0 commit comments