Skip to content

Commit f8060b7

Browse files
committed
Fixed typing
1 parent 9cfa7ca commit f8060b7

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

redis/asyncio/cluster.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
List,
1212
Mapping,
1313
Optional,
14+
Tuple,
1415
Type,
1516
TypeVar,
1617
Union,
@@ -516,7 +517,7 @@ def set_response_callback(self, command: str, callback: ResponseCallbackT) -> No
516517

517518
async def _determine_nodes(
518519
self, command: str, *args: Any, node_flag: Optional[str] = None
519-
) -> tuple[list["ClusterNode"], bool]:
520+
) -> Tuple[List["ClusterNode"], bool]:
520521
"""Determine which nodes should be executed the command on
521522
522523
Returns:

redis/cluster.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import threading
55
import time
66
from collections import OrderedDict
7-
from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union
7+
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
88

99
from redis.backoff import default_backoff
1010
from redis.client import CaseInsensitiveDict, PubSub, Redis, parse_scan
@@ -38,10 +38,6 @@
3838
str_if_bytes,
3939
)
4040

41-
TargetNodesT = TypeVar(
42-
"TargetNodesT", str, "ClusterNode", List["ClusterNode"], Dict[Any, "ClusterNode"]
43-
)
44-
4541

4642
def get_node_name(host: str, port: Union[str, int]) -> str:
4743
return f"{host}:{port}"
@@ -839,7 +835,7 @@ def set_response_callback(self, command, callback):
839835
"""Set a custom Response Callback"""
840836
self.cluster_response_callbacks[command] = callback
841837

842-
def _determine_nodes(self, *args, **kwargs) -> tuple[list["ClusterNode"], bool]:
838+
def _determine_nodes(self, *args, **kwargs) -> Tuple[List["ClusterNode"], bool]:
843839
"""Determine which nodes should be executed the command on
844840
845841
Returns:

tests/test_asyncio/test_cluster.py

+2
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,8 @@ async def test_default_node_is_replaced_after_exception(self, r):
807807
nodes = await r.cluster_nodes()
808808
assert "myself" not in nodes.get(curr_default_node.name).get("flags")
809809
assert r.get_default_node() != curr_default_node
810+
# Rollback to the old default node
811+
r.replace_default_node(curr_default_node)
810812

811813

812814
class TestClusterRedisCommands:

tests/test_cluster.py

+2
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,8 @@ def raise_connection_error():
813813
nodes = r.cluster_nodes()
814814
assert "myself" not in nodes.get(curr_default_node.name).get("flags")
815815
assert r.get_default_node() != curr_default_node
816+
# Rollback to the old default node
817+
r.replace_default_node(curr_default_node)
816818

817819

818820
@pytest.mark.onlycluster

0 commit comments

Comments
 (0)