Skip to content

Commit d958125

Browse files
fix: use KeysT for blpop and brpop keys parameter type annotation (#3987)
Fixes #3986 `blpop` and `brpop` accept a single key (str/bytes) or an iterable of keys, which is handled internally by `list_or_args`. However, both methods were annotated with the bare `List` type which made static type-checkers (e.g. Pylance, mypy) reject single-string arguments. The `KeysT = Union[KeyT, Iterable[KeyT]]` alias already exists in `redis.typing` and is imported in this module. Updating both method signatures to use `KeysT` aligns the annotations with the actual runtime behaviour and eliminates the false-positive type errors. Made-with: Cursor Co-authored-by: Turan Almammadov <16321061+turanalmammadov@users.noreply.github.com> Co-authored-by: petyaslavova <petya.slavova@redis.com>
1 parent 75bf91b commit d958125

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

redis/commands/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2900,7 +2900,7 @@ class ListCommands(CommandsProtocol):
29002900
"""
29012901

29022902
def blpop(
2903-
self, keys: List, timeout: Optional[Number] = 0
2903+
self, keys: KeysT, timeout: Optional[Number] = 0
29042904
) -> Union[Awaitable[list], list]:
29052905
"""
29062906
LPOP a value off of the first non-empty list
@@ -2921,7 +2921,7 @@ def blpop(
29212921
return self.execute_command("BLPOP", *keys)
29222922

29232923
def brpop(
2924-
self, keys: List, timeout: Optional[Number] = 0
2924+
self, keys: KeysT, timeout: Optional[Number] = 0
29252925
) -> Union[Awaitable[list], list]:
29262926
"""
29272927
RPOP a value off of the first non-empty list

0 commit comments

Comments
 (0)