From 466f9c2ad7bb65702b268081bcc753778f43f6a0 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 26 May 2022 07:53:56 -0700 Subject: [PATCH] redis: Fix unconstrained TypeVars in a few redis commands (#7942) Part of #7928 --- stubs/redis/redis/commands/core.pyi | 56 ++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/stubs/redis/redis/commands/core.pyi b/stubs/redis/redis/commands/core.pyi index d90b99d01..90bbd4238 100644 --- a/stubs/redis/redis/commands/core.pyi +++ b/stubs/redis/redis/commands/core.pyi @@ -635,20 +635,43 @@ class ScanCommands(Generic[_StrType]): def hscan_iter( self, name: _Key, match: _Key | None = ..., count: int | None = ... ) -> Iterator[tuple[_StrType, _StrType]]: ... + @overload + def zscan( + self, name: _Key, cursor: int = ..., match: _Key | None = ..., count: int | None = ... + ) -> tuple[int, list[tuple[_StrType, float]]]: ... + @overload def zscan( self, name: _Key, cursor: int = ..., match: _Key | None = ..., count: int | None = ..., - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + *, + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], ) -> tuple[int, list[tuple[_StrType, _ScoreCastFuncReturn]]]: ... + @overload + def zscan( + self, + name: _Key, + cursor: int, + match: _Key | None, + count: int | None, + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], + ) -> tuple[int, list[tuple[_StrType, _ScoreCastFuncReturn]]]: ... + @overload + def zscan_iter(self, name: _Key, match: _Key | None = ..., count: int | None = ...) -> Iterator[tuple[_StrType, float]]: ... + @overload def zscan_iter( self, name: _Key, match: _Key | None = ..., count: int | None = ..., - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + *, + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], + ) -> Iterator[tuple[_StrType, _ScoreCastFuncReturn]]: ... + @overload + def zscan_iter( + self, name: _Key, match: _Key | None, count: int | None, score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] ) -> Iterator[tuple[_StrType, _ScoreCastFuncReturn]]: ... class AsyncScanCommands(Generic[_StrType]): @@ -673,20 +696,45 @@ class AsyncScanCommands(Generic[_StrType]): def hscan_iter( self, name: _Key, match: _Key | None = ..., count: int | None = ... ) -> AsyncIterator[tuple[_StrType, _StrType]]: ... + @overload + async def zscan( + self, name: _Key, cursor: int = ..., match: _Key | None = ..., count: int | None = ... + ) -> tuple[int, list[tuple[_StrType, float]]]: ... + @overload async def zscan( self, name: _Key, cursor: int = ..., match: _Key | None = ..., count: int | None = ..., - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + *, + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], ) -> tuple[int, list[tuple[_StrType, _ScoreCastFuncReturn]]]: ... + @overload + async def zscan( + self, + name: _Key, + cursor: int, + match: _Key | None, + count: int | None, + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], + ) -> tuple[int, list[tuple[_StrType, _ScoreCastFuncReturn]]]: ... + @overload + def zscan_iter( + self, name: _Key, match: _Key | None = ..., count: int | None = ... + ) -> AsyncIterator[tuple[_StrType, float]]: ... + @overload def zscan_iter( self, name: _Key, match: _Key | None = ..., count: int | None = ..., - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + *, + score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], + ) -> AsyncIterator[tuple[_StrType, _ScoreCastFuncReturn]]: ... + @overload + def zscan_iter( + self, name: _Key, match: _Key | None, count: int | None, score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] ) -> AsyncIterator[tuple[_StrType, _ScoreCastFuncReturn]]: ... class SetCommands(Generic[_StrType]):