Skip to content

Invalid Default Argument For LMPOP #2414

Closed
@HassanAbouelela

Description

@HassanAbouelela

Version: Confirmed on redis-py 4.3.4, still in main. Redis 7.0.5

Platform: Python 3.10, Windows 10. Any OS and python version can reproduce.

Description:
The code for LMPOP gives the direction a default argument of None which is not a valid argument for that function and would raise an error:

>>> redis.lmpop(1, "example")
Traceback (most recent call last):
  ...
  File "site-packages\redis\commands\core.py", line 2551, in lmpop
    return self.execute_command("LMPOP", *args)
  File "site-packages\redis\client.py", line 1238, in execute_command
    return conn.retry.call_with_retry(
  ...
  File "site-packages\redis\connection.py", line 108, in encode
    raise DataError(
redis.exceptions.DataError: Invalid input of type: 'NoneType'. Convert to a bytes, string, int or float first.

Running something like redis.lmpop(1, "example", direction="LEFT") would not raise an error. The other functions around here do not have a default argument for direction.

Relevant code:

def lmpop(
self,
num_keys: int,
*args: List[str],
direction: str = None,
count: Optional[int] = 1,
) -> Union[Awaitable[list], list]:
"""
Pop ``count`` values (default 1) first non-empty list key from the list
of args provided key names.
For more information see https://redis.io/commands/lmpop
"""
args = [num_keys] + list(args) + [direction]
if count != 1:
args.extend(["COUNT", count])
return self.execute_command("LMPOP", *args)

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