From 9a70f627f5c9a213b4bdb0358fc84fdedb77894f Mon Sep 17 00:00:00 2001 From: Dave Johansen Date: Tue, 21 May 2024 01:17:49 -0600 Subject: [PATCH] Fix typing for address_remap (fixes #3234) (#3235) The address_remap callback received a tuple with the host and the port. Make this clear in the typing hints. --- redis/asyncio/cluster.py | 4 ++-- redis/cluster.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/redis/asyncio/cluster.py b/redis/asyncio/cluster.py index d5e5756045..719c2d2283 100644 --- a/redis/asyncio/cluster.py +++ b/redis/asyncio/cluster.py @@ -275,7 +275,7 @@ def __init__( ssl_min_version: Optional[ssl.TLSVersion] = None, ssl_ciphers: Optional[str] = None, protocol: Optional[int] = 2, - address_remap: Optional[Callable[[str, int], Tuple[str, int]]] = None, + address_remap: Optional[Callable[[Tuple[str, int]], Tuple[str, int]]] = None, cache_enabled: bool = False, client_cache: Optional[AbstractCache] = None, cache_max_size: int = 100, @@ -1152,7 +1152,7 @@ def __init__( startup_nodes: List["ClusterNode"], require_full_coverage: bool, connection_kwargs: Dict[str, Any], - address_remap: Optional[Callable[[str, int], Tuple[str, int]]] = None, + address_remap: Optional[Callable[[Tuple[str, int]], Tuple[str, int]]] = None, ) -> None: self.startup_nodes = {node.name: node for node in startup_nodes} self.require_full_coverage = require_full_coverage diff --git a/redis/cluster.py b/redis/cluster.py index e792d51867..6fde3530ef 100644 --- a/redis/cluster.py +++ b/redis/cluster.py @@ -506,7 +506,7 @@ def __init__( read_from_replicas: bool = False, dynamic_startup_nodes: bool = True, url: Optional[str] = None, - address_remap: Optional[Callable[[str, int], Tuple[str, int]]] = None, + address_remap: Optional[Callable[[Tuple[str, int]], Tuple[str, int]]] = None, **kwargs, ): """ @@ -1347,7 +1347,7 @@ def __init__( lock=None, dynamic_startup_nodes=True, connection_pool_class=ConnectionPool, - address_remap: Optional[Callable[[str, int], Tuple[str, int]]] = None, + address_remap: Optional[Callable[[Tuple[str, int]], Tuple[str, int]]] = None, **kwargs, ): self.nodes_cache = {}