Skip to content

Commit

Permalink
Fixed typing
Browse files Browse the repository at this point in the history
  • Loading branch information
barshaul committed Nov 20, 2022
1 parent 9cfa7ca commit f8060b7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion redis/asyncio/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
List,
Mapping,
Optional,
Tuple,
Type,
TypeVar,
Union,
Expand Down Expand Up @@ -516,7 +517,7 @@ def set_response_callback(self, command: str, callback: ResponseCallbackT) -> No

async def _determine_nodes(
self, command: str, *args: Any, node_flag: Optional[str] = None
) -> tuple[list["ClusterNode"], bool]:
) -> Tuple[List["ClusterNode"], bool]:
"""Determine which nodes should be executed the command on
Returns:
Expand Down
8 changes: 2 additions & 6 deletions redis/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import threading
import time
from collections import OrderedDict
from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

from redis.backoff import default_backoff
from redis.client import CaseInsensitiveDict, PubSub, Redis, parse_scan
Expand Down Expand Up @@ -38,10 +38,6 @@
str_if_bytes,
)

TargetNodesT = TypeVar(
"TargetNodesT", str, "ClusterNode", List["ClusterNode"], Dict[Any, "ClusterNode"]
)


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

def _determine_nodes(self, *args, **kwargs) -> tuple[list["ClusterNode"], bool]:
def _determine_nodes(self, *args, **kwargs) -> Tuple[List["ClusterNode"], bool]:
"""Determine which nodes should be executed the command on
Returns:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_asyncio/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,8 @@ async def test_default_node_is_replaced_after_exception(self, r):
nodes = await r.cluster_nodes()
assert "myself" not in nodes.get(curr_default_node.name).get("flags")
assert r.get_default_node() != curr_default_node
# Rollback to the old default node
r.replace_default_node(curr_default_node)


class TestClusterRedisCommands:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,8 @@ def raise_connection_error():
nodes = r.cluster_nodes()
assert "myself" not in nodes.get(curr_default_node.name).get("flags")
assert r.get_default_node() != curr_default_node
# Rollback to the old default node
r.replace_default_node(curr_default_node)


@pytest.mark.onlycluster
Expand Down

0 comments on commit f8060b7

Please sign in to comment.