Skip to content

Commit 9c8ad16

Browse files
Fix type hints for spop and srandmember methods (#3943)
The spop() and srandmember() methods were missing Awaitable in their return type hints, causing type errors when used with async Redis clients. Updated both methods to return Union[Awaitable[Union[str, List, None]], str, List, None] to properly support both sync and async usage, matching the pattern used by other set commands like smembers, smismember, and smove. Fixes #3886 Co-authored-by: petyaslavova <petya.slavova@redis.com>
1 parent 34c73c7 commit 9c8ad16

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

redis/commands/core.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3761,7 +3761,9 @@ def smove(self, src: KeyT, dst: KeyT, value: str) -> Union[Awaitable[bool], bool
37613761
"""
37623762
return self.execute_command("SMOVE", src, dst, value)
37633763

3764-
def spop(self, name: KeyT, count: Optional[int] = None) -> Union[str, List, None]:
3764+
def spop(
3765+
self, name: KeyT, count: Optional[int] = None
3766+
) -> Union[Awaitable[Union[str, List, None]], str, List, None]:
37653767
"""
37663768
Remove and return a random member of set ``name``
37673769
@@ -3772,7 +3774,7 @@ def spop(self, name: KeyT, count: Optional[int] = None) -> Union[str, List, None
37723774

37733775
def srandmember(
37743776
self, name: KeyT, number: Optional[int] = None
3775-
) -> Union[str, List, None]:
3777+
) -> Union[Awaitable[Union[str, List, None]], str, List, None]:
37763778
"""
37773779
If ``number`` is None, returns a random member of set ``name``.
37783780

0 commit comments

Comments
 (0)