Skip to content

Commit bf583da

Browse files
author
Guilhem C
authored
redis: complete redis.utils stubs (#5067)
1 parent 08b26b9 commit bf583da

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

stubs/redis/redis/utils.pyi

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
from typing import Any
1+
from typing import Any, ContextManager, Optional, Text, TypeVar, overload
2+
from typing_extensions import Literal
23

3-
HIREDIS_AVAILABLE: Any
4+
from .client import Pipeline, Redis
45

5-
def from_url(url, db=..., **kwargs): ...
6-
def pipeline(redis_obj): ...
6+
_T = TypeVar("_T")
7+
8+
HIREDIS_AVAILABLE: bool
9+
@overload
10+
def from_url(url: Text, db: Optional[int] = ..., *, decode_responses: Literal[True], **kwargs: Any) -> Redis[str]: ...
11+
@overload
12+
def from_url(url: Text, db: Optional[int] = ..., *, decode_responses: Literal[False] = ..., **kwargs: Any) -> Redis[bytes]: ...
13+
@overload
14+
def str_if_bytes(value: bytes) -> str: ... # type: ignore
15+
@overload
16+
def str_if_bytes(value: _T) -> _T: ...
17+
def safe_str(value: object) -> str: ...
18+
def pipeline(redis_obj: Redis) -> ContextManager[Pipeline]: ...
719

820
class dummy: ...

0 commit comments

Comments
 (0)