From c730213dbcdae1b1855d5961f33fd5b817a92d78 Mon Sep 17 00:00:00 2001 From: Petya Slavova Date: Mon, 6 Oct 2025 20:16:34 +0300 Subject: [PATCH] Fixing several *arg type hints in core.py and json module commands --- redis/commands/core.py | 24 +++++++++++------------- redis/commands/json/commands.py | 4 ++-- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/redis/commands/core.py b/redis/commands/core.py index ad21885b3d..d3d802dfb7 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -830,7 +830,7 @@ def command_list( return self.execute_command("COMMAND LIST", *pieces) - def command_getkeysandflags(self, *args: List[str]) -> List[Union[str, List[str]]]: + def command_getkeysandflags(self, *args: str) -> List[Union[str, List[str]]]: """ Returns array of keys from a full Redis command and their usage flags. @@ -848,7 +848,7 @@ def command_docs(self, *args): ) def config_get( - self, pattern: PatternT = "*", *args: List[PatternT], **kwargs + self, pattern: PatternT = "*", *args: PatternT, **kwargs ) -> ResponseT: """ Return a dictionary of configuration based on the ``pattern`` @@ -861,7 +861,7 @@ def config_set( self, name: KeyT, value: EncodableT, - *args: List[Union[KeyT, EncodableT]], + *args: Union[KeyT, EncodableT], **kwargs, ) -> ResponseT: """Set config item ``name`` with ``value`` @@ -987,9 +987,7 @@ def select(self, index: int, **kwargs) -> ResponseT: """ return self.execute_command("SELECT", index, **kwargs) - def info( - self, section: Optional[str] = None, *args: List[str], **kwargs - ) -> ResponseT: + def info(self, section: Optional[str] = None, *args: str, **kwargs) -> ResponseT: """ Returns a dictionary containing information about the Redis server @@ -2606,7 +2604,7 @@ def blmpop( self, timeout: float, numkeys: int, - *args: List[str], + *args: str, direction: str, count: Optional[int] = 1, ) -> Optional[list]: @@ -2619,14 +2617,14 @@ def blmpop( For more information, see https://redis.io/commands/blmpop """ - args = [timeout, numkeys, *args, direction, "COUNT", count] + cmd_args = [timeout, numkeys, *args, direction, "COUNT", count] - return self.execute_command("BLMPOP", *args) + return self.execute_command("BLMPOP", *cmd_args) def lmpop( self, num_keys: int, - *args: List[str], + *args: str, direction: str, count: Optional[int] = 1, ) -> Union[Awaitable[list], list]: @@ -2636,11 +2634,11 @@ def lmpop( For more information, see https://redis.io/commands/lmpop """ - args = [num_keys] + list(args) + [direction] + cmd_args = [num_keys] + list(args) + [direction] if count != 1: - args.extend(["COUNT", count]) + cmd_args.extend(["COUNT", count]) - return self.execute_command("LMPOP", *args) + return self.execute_command("LMPOP", *cmd_args) def lindex( self, name: str, index: int diff --git a/redis/commands/json/commands.py b/redis/commands/json/commands.py index 48849e1888..f278daf7a7 100644 --- a/redis/commands/json/commands.py +++ b/redis/commands/json/commands.py @@ -14,7 +14,7 @@ class JSONCommands: """json commands.""" def arrappend( - self, name: str, path: Optional[str] = Path.root_path(), *args: List[JsonType] + self, name: str, path: Optional[str] = Path.root_path(), *args: JsonType ) -> List[Optional[int]]: """Append the objects ``args`` to the array under the ``path` in key ``name``. @@ -52,7 +52,7 @@ def arrindex( return self.execute_command("JSON.ARRINDEX", *pieces, keys=[name]) def arrinsert( - self, name: str, path: str, index: int, *args: List[JsonType] + self, name: str, path: str, index: int, *args: JsonType ) -> List[Optional[int]]: """Insert the objects ``args`` to the array at index ``index`` under the ``path` in key ``name``.