mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
redis: Add _Encodable type alias (#8638)
This commit is contained in:
@@ -8,7 +8,7 @@ from typing_extensions import Literal
|
||||
from redis.client import CaseInsensitiveDict, PubSub, Redis, _ParseResponseOptions
|
||||
from redis.commands import CommandsParser, RedisClusterCommands
|
||||
from redis.commands.core import _StrType
|
||||
from redis.connection import BaseParser, Connection, ConnectionPool, Encoder, _ConnectionPoolOptions
|
||||
from redis.connection import BaseParser, Connection, ConnectionPool, Encoder, _ConnectionPoolOptions, _Encodable
|
||||
from redis.exceptions import MovedError, RedisError
|
||||
from redis.typing import EncodableT
|
||||
|
||||
@@ -86,8 +86,7 @@ class RedisCluster(AbstractRedisCluster, RedisClusterCommands[_StrType], Generic
|
||||
def get_replicas(self) -> list[ClusterNode]: ...
|
||||
def get_random_node(self) -> ClusterNode: ...
|
||||
def get_nodes(self) -> list[ClusterNode]: ...
|
||||
# TODO: use type alias for `str | bytes | memoryview | bool | float`
|
||||
def get_node_from_key(self, key: str | bytes | memoryview | bool | float, replica: bool = ...) -> ClusterNode | None: ...
|
||||
def get_node_from_key(self, key: _Encodable, replica: bool = ...) -> ClusterNode | None: ...
|
||||
def get_default_node(self) -> ClusterNode | None: ...
|
||||
def set_default_node(self, node: ClusterNode | None) -> bool: ...
|
||||
def monitor(self, target_node: Any | None = ...): ...
|
||||
@@ -103,7 +102,7 @@ class RedisCluster(AbstractRedisCluster, RedisClusterCommands[_StrType], Generic
|
||||
lock_class: type[Incomplete] | None = ...,
|
||||
thread_local: bool = ...,
|
||||
): ...
|
||||
def keyslot(self, key: str | bytes | memoryview | bool | float) -> int: ...
|
||||
def keyslot(self, key: _Encodable) -> int: ...
|
||||
def determine_slot(self, *args): ...
|
||||
def get_encoder(self) -> Encoder: ...
|
||||
def get_connection_kwargs(self) -> dict[str, Any]: ...
|
||||
|
||||
@@ -68,12 +68,14 @@ class HiredisParser(BaseParser):
|
||||
|
||||
DefaultParser: type[BaseParser] # Hiredis or PythonParser
|
||||
|
||||
_Encodable: TypeAlias = str | bytes | memoryview | bool | float
|
||||
|
||||
class Encoder:
|
||||
encoding: str
|
||||
encoding_errors: str
|
||||
decode_responses: bool
|
||||
def __init__(self, encoding: str, encoding_errors: str, decode_responses: bool) -> None: ...
|
||||
def encode(self, value: str | bytes | memoryview | bool | float) -> bytes: ...
|
||||
def encode(self, value: _Encodable) -> bytes: ...
|
||||
def decode(self, value: str | bytes | memoryview, force: bool = ...) -> str: ...
|
||||
|
||||
class Connection:
|
||||
|
||||
Reference in New Issue
Block a user