Skip to content

Commit 550803e

Browse files
committed
improve typing
1 parent a14286f commit 550803e

File tree

1 file changed

+6
-2
lines changed
  • packages/service-library/src/servicelib/redis

1 file changed

+6
-2
lines changed

packages/service-library/src/servicelib/redis/_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from collections.abc import Awaitable
3-
from typing import Any
3+
from typing import ParamSpec, TypeVar
44

55
import redis.exceptions
66
from redis.asyncio.lock import Lock
@@ -28,7 +28,11 @@ async def auto_extend_lock(lock: Lock) -> None:
2828
raise LockLostError(lock=lock) from exc
2929

3030

31-
async def handle_redis_returns_union_types(result: Any | Awaitable[Any]) -> Any:
31+
P = ParamSpec("P")
32+
R = TypeVar("R")
33+
34+
35+
async def handle_redis_returns_union_types(result: R | Awaitable[R]) -> R:
3236
"""Used to handle mypy issues with redis 5.x return types"""
3337
if isinstance(result, Awaitable):
3438
return await result

0 commit comments

Comments
 (0)