From 4967c8bc12587d503a9ffcbeb3b716b1e97f19cc Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Wed, 15 Jun 2022 18:14:13 +0100 Subject: [PATCH] `redis`: fix more unconstrained `TypeVar`s (#8084) --- stubs/redis/redis/commands/core.pyi | 100 ++++++++++++++++++++++++---- 1 file changed, 88 insertions(+), 12 deletions(-) diff --git a/stubs/redis/redis/commands/core.pyi b/stubs/redis/redis/commands/core.pyi index 90bbd4238..d6af3655b 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,7 +1105,36 @@ 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, + start: int, + end: int, + desc: bool = ..., + *, + withscores: Literal[True], + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], byscore: bool = ..., bylex: bool = ..., offset: int | None = ..., @@ -1083,12 +1149,12 @@ class AsyncSortedSetCommands(Generic[_StrType]): desc: bool = ..., *, withscores: Literal[True], - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + score_cast_func: Callable[[_StrType], float] = ..., byscore: bool = ..., bylex: bool = ..., offset: int | None = ..., num: int | None = ..., - ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... + ) -> list[tuple[_StrType, float]]: ... @overload async def zrange( self, @@ -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,