From 920d601c347a96483ebfa30d441303991a45a88e Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Wed, 15 Jun 2022 16:00:44 +0100 Subject: [PATCH] `redis`: fix more unconstrained `TypeVar`s --- stubs/redis/redis/commands/core.pyi | 98 +++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 11 deletions(-) diff --git a/stubs/redis/redis/commands/core.pyi b/stubs/redis/redis/commands/core.pyi index 90bbd4238413..d6af3655b239 100644 --- a/stubs/redis/redis/commands/core.pyi +++ b/stubs/redis/redis/commands/core.pyi @@ -904,7 +904,7 @@ class SortedSetCommands(Generic[_StrType]): end: int, desc: bool, withscores: Literal[True], - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], byscore: bool = ..., bylex: bool = ..., offset: int | None = ..., @@ -916,16 +916,43 @@ class SortedSetCommands(Generic[_StrType]): name: _Key, start: int, end: int, - desc: bool = ..., + desc: bool, + withscores: Literal[True], + score_cast_func: Callable[[_StrType], float] = ..., + byscore: bool = ..., + bylex: bool = ..., + offset: int | None = ..., + num: int | None = ..., + ) -> list[tuple[_StrType, float]]: ... + @overload + def zrange( + self, + name: _Key, + start: int, + end: int, *, withscores: Literal[True], - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], byscore: bool = ..., bylex: bool = ..., offset: int | None = ..., num: int | None = ..., ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... @overload + def zrange( + self, + name: _Key, + start: int, + end: int, + *, + withscores: Literal[True], + score_cast_func: Callable[[_StrType], float] = ..., + byscore: bool = ..., + bylex: bool = ..., + offset: int | None = ..., + num: int | None = ..., + ) -> list[tuple[_StrType, float]]: ... + @overload def zrange( self, name: _Key, @@ -946,9 +973,11 @@ class SortedSetCommands(Generic[_StrType]): start: int, end: int, withscores: Literal[True], - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... @overload + def zrevrange(self, name: _Key, start: int, end: int, withscores: Literal[True]) -> list[tuple[_StrType, float]]: ... + @overload def zrevrange( self, name: _Key, start: int, end: int, withscores: bool = ..., score_cast_func: Callable[[Any], Any] = ... ) -> list[_StrType]: ... @@ -980,9 +1009,13 @@ class SortedSetCommands(Generic[_StrType]): num: int | None = ..., *, withscores: Literal[True], - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... @overload + def zrangebyscore( + self, name: _Key, min: _Value, max: _Value, start: int | None = ..., num: int | None = ..., *, withscores: Literal[True] + ) -> list[tuple[_StrType, float]]: ... + @overload def zrangebyscore( self, name: _Key, @@ -1003,9 +1036,13 @@ class SortedSetCommands(Generic[_StrType]): num: int | None = ..., *, withscores: Literal[True], - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... @overload + def zrevrangebyscore( + self, name: _Key, max: _Value, min: _Value, start: int | None = ..., num: int | None = ..., *, withscores: Literal[True] + ) -> list[tuple[_StrType, float]]: ... + @overload def zrevrangebyscore( self, name: _Key, @@ -1068,13 +1105,27 @@ class AsyncSortedSetCommands(Generic[_StrType]): end: int, desc: bool, withscores: Literal[True], - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], byscore: bool = ..., bylex: bool = ..., offset: int | None = ..., num: int | None = ..., ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... @overload + async def zrange( + self, + name: _Key, + start: int, + end: int, + desc: bool, + withscores: Literal[True], + score_cast_func: Callable[[_StrType], float] = ..., + byscore: bool = ..., + bylex: bool = ..., + offset: int | None = ..., + num: int | None = ..., + ) -> list[tuple[_StrType, float]]: ... + @overload async def zrange( self, name: _Key, @@ -1083,13 +1134,28 @@ class AsyncSortedSetCommands(Generic[_StrType]): desc: bool = ..., *, withscores: Literal[True], - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], byscore: bool = ..., bylex: bool = ..., offset: int | None = ..., num: int | None = ..., ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... @overload + async def zrange( + self, + name: _Key, + start: int, + end: int, + desc: bool = ..., + *, + withscores: Literal[True], + score_cast_func: Callable[[_StrType], float] = ..., + byscore: bool = ..., + bylex: bool = ..., + offset: int | None = ..., + num: int | None = ..., + ) -> list[tuple[_StrType, float]]: ... + @overload async def zrange( self, name: _Key, @@ -1110,9 +1176,11 @@ class AsyncSortedSetCommands(Generic[_StrType]): start: int, end: int, withscores: Literal[True], - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... @overload + async def zrevrange(self, name: _Key, start: int, end: int, withscores: Literal[True]) -> list[tuple[_StrType, float]]: ... + @overload async def zrevrange( self, name: _Key, start: int, end: int, withscores: bool = ..., score_cast_func: Callable[[Any], Any] = ... ) -> list[_StrType]: ... @@ -1144,9 +1212,13 @@ class AsyncSortedSetCommands(Generic[_StrType]): num: int | None = ..., *, withscores: Literal[True], - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... @overload + async def zrangebyscore( + self, name: _Key, min: _Value, max: _Value, start: int | None = ..., num: int | None = ..., *, withscores: Literal[True] + ) -> list[tuple[_StrType, float]]: ... + @overload async def zrangebyscore( self, name: _Key, @@ -1167,9 +1239,13 @@ class AsyncSortedSetCommands(Generic[_StrType]): num: int | None = ..., *, withscores: Literal[True], - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... @overload + async def zrevrangebyscore( + self, name: _Key, max: _Value, min: _Value, start: int | None = ..., num: int | None = ..., *, withscores: Literal[True] + ) -> list[tuple[_StrType, float]]: ... + @overload async def zrevrangebyscore( self, name: _Key,