From e71df3655ef9dfbac8da4d15e18543f544d517b5 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 24 May 2022 19:22:45 -0700 Subject: [PATCH 1/3] redis: Fix unconstrained TypeVars in a few redis commands Part of #7928 --- stubs/redis/redis/commands/core.pyi | 80 +++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 4 deletions(-) diff --git a/stubs/redis/redis/commands/core.pyi b/stubs/redis/redis/commands/core.pyi index d90b99d01f66..4bbcf0ac9d64 100644 --- a/stubs/redis/redis/commands/core.pyi +++ b/stubs/redis/redis/commands/core.pyi @@ -635,20 +635,56 @@ class ScanCommands(Generic[_StrType]): def hscan_iter( self, name: _Key, match: _Key | None = ..., count: int | None = ... ) -> Iterator[tuple[_StrType, _StrType]]: ... + @overloadd def zscan( self, name: _Key, cursor: int = ..., match: _Key | None = ..., count: int | None = ..., - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + ) -> tuple[int, list[tuple[_StrType, float]]]: ... + @overloadd + 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( + 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 = ..., - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + ) -> Iterator[tuple[_StrType, float]]: ... + @overload + def zscan_iter( + self, + name: _Key, + match: _Key | None = ..., + count: int | None = ..., + *, + 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 +709,56 @@ class AsyncScanCommands(Generic[_StrType]): def hscan_iter( self, name: _Key, match: _Key | None = ..., count: int | None = ... ) -> AsyncIterator[tuple[_StrType, _StrType]]: ... + @overloadd 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, float]]]: ... + @overloadd + 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 + 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 = ..., - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] = ..., + ) -> AsyncIterator[tuple[_StrType, float]]: ... + @overload + def zscan_iter( + self, + name: _Key, + match: _Key | None = ..., + count: int | None = ..., + *, + 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]): From 30ec9544d751dde4e74bc1fac9426126846d3a91 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 24 May 2022 19:23:37 -0700 Subject: [PATCH 2/3] overloadd --- stubs/redis/redis/commands/core.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stubs/redis/redis/commands/core.pyi b/stubs/redis/redis/commands/core.pyi index 4bbcf0ac9d64..249861c9638d 100644 --- a/stubs/redis/redis/commands/core.pyi +++ b/stubs/redis/redis/commands/core.pyi @@ -635,7 +635,7 @@ class ScanCommands(Generic[_StrType]): def hscan_iter( self, name: _Key, match: _Key | None = ..., count: int | None = ... ) -> Iterator[tuple[_StrType, _StrType]]: ... - @overloadd + @overload def zscan( self, name: _Key, @@ -643,7 +643,7 @@ class ScanCommands(Generic[_StrType]): match: _Key | None = ..., count: int | None = ..., ) -> tuple[int, list[tuple[_StrType, float]]]: ... - @overloadd + @overload def zscan( self, name: _Key, @@ -709,7 +709,7 @@ class AsyncScanCommands(Generic[_StrType]): def hscan_iter( self, name: _Key, match: _Key | None = ..., count: int | None = ... ) -> AsyncIterator[tuple[_StrType, _StrType]]: ... - @overloadd + @overload async def zscan( self, name: _Key, @@ -717,7 +717,7 @@ class AsyncScanCommands(Generic[_StrType]): match: _Key | None = ..., count: int | None = ..., ) -> tuple[int, list[tuple[_StrType, float]]]: ... - @overloadd + @overload async def zscan( self, name: _Key, From bf5126041d22a31cd1c7bf399b39d0bef1ea9b59 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 May 2022 02:24:19 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/redis/redis/commands/core.pyi | 36 +++++------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/stubs/redis/redis/commands/core.pyi b/stubs/redis/redis/commands/core.pyi index 249861c9638d..90bbd4238413 100644 --- a/stubs/redis/redis/commands/core.pyi +++ b/stubs/redis/redis/commands/core.pyi @@ -637,11 +637,7 @@ class ScanCommands(Generic[_StrType]): ) -> Iterator[tuple[_StrType, _StrType]]: ... @overload def zscan( - self, - name: _Key, - cursor: int = ..., - match: _Key | None = ..., - count: int | None = ..., + self, name: _Key, cursor: int = ..., match: _Key | None = ..., count: int | None = ... ) -> tuple[int, list[tuple[_StrType, float]]]: ... @overload def zscan( @@ -663,12 +659,7 @@ class ScanCommands(Generic[_StrType]): 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]]: ... + def zscan_iter(self, name: _Key, match: _Key | None = ..., count: int | None = ...) -> Iterator[tuple[_StrType, float]]: ... @overload def zscan_iter( self, @@ -680,11 +671,7 @@ class ScanCommands(Generic[_StrType]): ) -> Iterator[tuple[_StrType, _ScoreCastFuncReturn]]: ... @overload def zscan_iter( - self, - name: _Key, - match: _Key | None, - count: int | None, - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], + self, name: _Key, match: _Key | None, count: int | None, score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] ) -> Iterator[tuple[_StrType, _ScoreCastFuncReturn]]: ... class AsyncScanCommands(Generic[_StrType]): @@ -711,11 +698,7 @@ class AsyncScanCommands(Generic[_StrType]): ) -> AsyncIterator[tuple[_StrType, _StrType]]: ... @overload async def zscan( - self, - name: _Key, - cursor: int = ..., - match: _Key | None = ..., - count: int | None = ..., + self, name: _Key, cursor: int = ..., match: _Key | None = ..., count: int | None = ... ) -> tuple[int, list[tuple[_StrType, float]]]: ... @overload async def zscan( @@ -738,10 +721,7 @@ class AsyncScanCommands(Generic[_StrType]): ) -> tuple[int, list[tuple[_StrType, _ScoreCastFuncReturn]]]: ... @overload def zscan_iter( - self, - name: _Key, - match: _Key | None = ..., - count: int | None = ..., + self, name: _Key, match: _Key | None = ..., count: int | None = ... ) -> AsyncIterator[tuple[_StrType, float]]: ... @overload def zscan_iter( @@ -754,11 +734,7 @@ class AsyncScanCommands(Generic[_StrType]): ) -> AsyncIterator[tuple[_StrType, _ScoreCastFuncReturn]]: ... @overload def zscan_iter( - self, - name: _Key, - match: _Key | None, - count: int | None, - score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn], + self, name: _Key, match: _Key | None, count: int | None, score_cast_func: Callable[[_StrType], _ScoreCastFuncReturn] ) -> AsyncIterator[tuple[_StrType, _ScoreCastFuncReturn]]: ... class SetCommands(Generic[_StrType]):