Skip to content

Type hint Lock.extend's additional_time as a Number #3522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Type hint Lock.extend's additional_time as a Number
It must be possible for the function to receive floats, as the docstring
and the code suggest.
  • Loading branch information
Perlence committed Feb 21, 2025
commit e080b9b33d6c009d6a141f8dc17e23f9b52091d4
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
Loading