Skip to content

Commit d9df523

Browse files
committed
fix typing
1 parent 8e97205 commit d9df523

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

packages/service-library/src/servicelib/redis_utils.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818

1919
def exclusive(
20-
redis: RedisClientSDK | Callable[P, RedisClientSDK],
20+
redis: RedisClientSDK | Callable[..., RedisClientSDK],
2121
*,
22-
lock_key: str | Callable[P, str],
22+
lock_key: str | Callable[..., str],
2323
lock_value: bytes | str | None = None,
2424
) -> Callable[[Callable[P, Awaitable[R]]], Callable[P, Awaitable[R]]]:
2525
"""
@@ -43,14 +43,12 @@ def exclusive(
4343
def decorator(func: Callable[P, Awaitable[R]]) -> Callable[P, Awaitable[R]]:
4444
@functools.wraps(func)
4545
async def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
46-
redis_lock_key = lock_key
47-
if callable(lock_key):
48-
redis_lock_key = lock_key(*args, **kwargs)
46+
redis_lock_key = (
47+
lock_key(*args, **kwargs) if callable(lock_key) else lock_key
48+
)
4949
assert isinstance(redis_lock_key, str) # nosec
5050

51-
redis_client = redis
52-
if callable(redis):
53-
redis_client = redis(*args, **kwargs)
51+
redis_client = redis(*args, **kwargs) if callable(redis) else redis
5452
assert isinstance(redis_client, RedisClientSDK) # nosec
5553

5654
async with redis_client.lock_context(

0 commit comments

Comments
 (0)