Skip to content

Commit

Permalink
Type hint Lock.extend's additional_time as a Number (#3522)
Browse files Browse the repository at this point in the history
It must be possible for the function to receive floats, as the docstring
and the code suggest.
  • Loading branch information
Perlence authored Feb 21, 2025
1 parent 8427c7b commit 75cac31
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions redis/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def do_release(self, expected_token: str) -> None:
lock_name=self.name,
)

def extend(self, additional_time: int, replace_ttl: bool = False) -> bool:
def extend(self, additional_time: Number, replace_ttl: bool = False) -> bool:
"""
Adds more time to an already acquired lock.
Expand All @@ -281,7 +281,7 @@ def extend(self, additional_time: int, replace_ttl: bool = False) -> bool:
raise LockError("Cannot extend a lock with no timeout", lock_name=self.name)
return self.do_extend(additional_time, replace_ttl)

def do_extend(self, additional_time: int, replace_ttl: bool) -> bool:
def do_extend(self, additional_time: Number, replace_ttl: bool) -> bool:
additional_time = int(additional_time * 1000)
if not bool(
self.lua_extend(
Expand Down

0 comments on commit 75cac31

Please sign in to comment.