-
-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy path_typing.py
More file actions
45 lines (38 loc) · 1.21 KB
/
_typing.py
File metadata and controls
45 lines (38 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import sys
from typing import Tuple, Union, Dict, Any, List
import redis
if sys.version_info < (3, 8):
from typing_extensions import Literal
else:
from typing import Literal
if sys.version_info >= (3, 11):
from typing import Self
from asyncio import timeout as async_timeout
else:
from async_timeout import timeout as async_timeout
from typing_extensions import Self
try:
from importlib import metadata
except ImportError: # for Python < 3.8
import importlib_metadata as metadata # type: ignore
lib_version = metadata.version("fakeredis")
VersionType = Tuple[int, ...]
ServerType = Literal["redis", "dragonfly", "valkey"]
JsonType = Union[str, int, float, bool, None, Dict[str, Any], List[Any]]
RaiseErrorTypes = (redis.ResponseError, redis.AuthenticationError)
ResponseErrorType = redis.ResponseError
try:
import valkey
RaiseErrorTypes = (redis.ResponseError, redis.AuthenticationError, valkey.ResponseError, valkey.AuthenticationError)
ResponseErrorType = Union[redis.ResponseError, valkey.ResponseError]
except ImportError:
pass
__all__ = [
"Self",
"async_timeout",
"VersionType",
"ServerType",
"lib_version",
"RaiseErrorTypes",
"ResponseErrorType",
]