Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions redis/asyncio/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import threading
import uuid
from types import SimpleNamespace
from typing import TYPE_CHECKING, Awaitable, Optional, Union
from typing import TYPE_CHECKING, Awaitable, Literal, Optional, Union

from redis.exceptions import LockError, LockNotOwnedError
from redis.typing import Number
Expand Down Expand Up @@ -284,7 +284,7 @@ async def do_release(self, expected_token: bytes) -> None:

def extend(
self, additional_time: Number, replace_ttl: bool = False
) -> Awaitable[bool]:
) -> Awaitable[Literal[True]]:
"""
Adds more time to an already acquired lock.

Expand All @@ -301,7 +301,7 @@ def extend(
raise LockError("Cannot extend a lock with no timeout")
return self.do_extend(additional_time, replace_ttl)

async def do_extend(self, additional_time, replace_ttl) -> bool:
async def do_extend(self, additional_time, replace_ttl) -> Literal[True]:
additional_time = int(additional_time * 1000)
if not bool(
await self.lua_extend(
Expand Down
6 changes: 3 additions & 3 deletions redis/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import time as mod_time
import uuid
from types import SimpleNamespace, TracebackType
from typing import Optional, Type
from typing import Literal, Optional, Type

from redis.exceptions import LockError, LockNotOwnedError
from redis.typing import Number
Expand Down Expand Up @@ -284,7 +284,7 @@ def do_release(self, expected_token: str) -> None:
lock_name=self.name,
)

def extend(self, additional_time: Number, replace_ttl: bool = False) -> bool:
def extend(self, additional_time: Number, replace_ttl: bool = False) -> Literal[True]:
"""
Adds more time to an already acquired lock.

Expand All @@ -301,7 +301,7 @@ def extend(self, additional_time: Number, 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: Number, replace_ttl: bool) -> bool:
def do_extend(self, additional_time: Number, replace_ttl: bool) -> Literal[True]:
additional_time = int(additional_time * 1000)
if not bool(
self.lua_extend(
Expand Down