Skip to content

*arg types in redis/commands/core.py and redis/commands/json/commands.py appear to be wrong #3780

@jogo-openai

Description

@jogo-openai

PEP484 says

When using the short form, for *args and **kwds, put 1 or 2 stars in front of the corresponding type annotation. (As with Python 3 annotations, the annotation here denotes the type of the individual argument values, not of the tuple/dict that you receive as the special argument value args or kwd

https://peps.python.org/pep-0484/#arbitrary-argument-lists-and-default-argument-values

Example mypy error:
Argument 3 to "blmpop" of "ListCommands" has incompatible type "str"; expected "list[str]"

So I think this change should fix it:

diff --git c/redis/commands/core.py w/redis/commands/core.py
index 737b098..4ba6430 100644
--- c/redis/commands/core.py
+++ w/redis/commands/core.py
@@ -830,7 +830,7 @@ class ManagementCommands(CommandsProtocol):
 
         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 @@ class ManagementCommands(CommandsProtocol):
         )
 
     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 @@ class ManagementCommands(CommandsProtocol):
         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 @@ class ManagementCommands(CommandsProtocol):
         """
         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
 
@@ -2599,7 +2597,7 @@ class ListCommands(CommandsProtocol):
         self,
         timeout: float,
         numkeys: int,
-        *args: List[str],
+        *args: str,
         direction: str,
         count: Optional[int] = 1,
     ) -> Optional[list]:
@@ -2619,7 +2617,7 @@ class ListCommands(CommandsProtocol):
     def lmpop(
         self,
         num_keys: int,
-        *args: List[str],
+        *args: str,
         direction: str,
         count: Optional[int] = 1,
     ) -> Union[Awaitable[list], list]:
diff --git c/redis/commands/json/commands.py w/redis/commands/json/commands.py
index 48849e1..f278daf 100644
--- c/redis/commands/json/commands.py
+++ w/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 @@ class JSONCommands:
         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``.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions