Skip to content

Commit f234f8b

Browse files
committed
fix test
1 parent 1b40a31 commit f234f8b

14 files changed

+41
-38
lines changed

redis/_parsers/helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,9 +841,9 @@ def string_keys_to_dict(key_string, callback):
841841
),
842842
"COMMAND": parse_command_resp3,
843843
"CONFIG GET": lambda r: {
844-
str_if_bytes(key)
845-
if key is not None
846-
else None: (str_if_bytes(value) if value is not None else None)
844+
str_if_bytes(key) if key is not None else None: (
845+
str_if_bytes(value) if value is not None else None
846+
)
847847
for key, value in r.items()
848848
},
849849
"MEMORY STATS": lambda r: {str_if_bytes(key): value for key, value in r.items()},

redis/asyncio/client.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,11 @@
8888

8989

9090
class ResponseCallbackProtocol(Protocol):
91-
def __call__(self, response: Any, **kwargs):
92-
...
91+
def __call__(self, response: Any, **kwargs): ...
9392

9493

9594
class AsyncResponseCallbackProtocol(Protocol):
96-
async def __call__(self, response: Any, **kwargs):
97-
...
95+
async def __call__(self, response: Any, **kwargs): ...
9896

9997

10098
ResponseCallbackT = Union[ResponseCallbackProtocol, AsyncResponseCallbackProtocol]
@@ -1220,13 +1218,11 @@ async def run(
12201218

12211219

12221220
class PubsubWorkerExceptionHandler(Protocol):
1223-
def __call__(self, e: BaseException, pubsub: PubSub):
1224-
...
1221+
def __call__(self, e: BaseException, pubsub: PubSub): ...
12251222

12261223

12271224
class AsyncPubsubWorkerExceptionHandler(Protocol):
1228-
async def __call__(self, e: BaseException, pubsub: PubSub):
1229-
...
1225+
async def __call__(self, e: BaseException, pubsub: PubSub): ...
12301226

12311227

12321228
PSWorkerThreadExcHandlerT = Union[

redis/asyncio/cluster.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,10 @@ def __init__(
402402
self.command_flags = self.__class__.COMMAND_FLAGS.copy()
403403
self.response_callbacks = kwargs["response_callbacks"]
404404
self.result_callbacks = self.__class__.RESULT_CALLBACKS.copy()
405-
self.result_callbacks[
406-
"CLUSTER SLOTS"
407-
] = lambda cmd, res, **kwargs: parse_cluster_slots(
408-
list(res.values())[0], **kwargs
405+
self.result_callbacks["CLUSTER SLOTS"] = (
406+
lambda cmd, res, **kwargs: parse_cluster_slots(
407+
list(res.values())[0], **kwargs
408+
)
409409
)
410410

411411
self._initialize = True
@@ -1318,9 +1318,9 @@ async def initialize(self) -> None:
13181318
)
13191319
tmp_slots[i].append(target_replica_node)
13201320
# add this node to the nodes cache
1321-
tmp_nodes_cache[
1322-
target_replica_node.name
1323-
] = target_replica_node
1321+
tmp_nodes_cache[target_replica_node.name] = (
1322+
target_replica_node
1323+
)
13241324
else:
13251325
# Validate that 2 nodes want to use the same slot cache
13261326
# setup

redis/asyncio/connection.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,11 @@ class _Sentinel(enum.Enum):
8787

8888

8989
class ConnectCallbackProtocol(Protocol):
90-
def __call__(self, connection: "AbstractConnection"):
91-
...
90+
def __call__(self, connection: "AbstractConnection"): ...
9291

9392

9493
class AsyncConnectCallbackProtocol(Protocol):
95-
async def __call__(self, connection: "AbstractConnection"):
96-
...
94+
async def __call__(self, connection: "AbstractConnection"): ...
9795

9896

9997
ConnectCallbackT = Union[ConnectCallbackProtocol, AsyncConnectCallbackProtocol]
@@ -698,7 +696,7 @@ def _cache_invalidation_process(
698696
and the second string is the list of keys to invalidate.
699697
(if the list of keys is None, then all keys are invalidated)
700698
"""
701-
if data[1] is not None:
699+
if data[1] is None:
702700
self.client_cache.flush()
703701
else:
704702
for key in data[1]:

redis/cluster.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,9 +1582,9 @@ def initialize(self):
15821582
)
15831583
tmp_slots[i].append(target_replica_node)
15841584
# add this node to the nodes cache
1585-
tmp_nodes_cache[
1586-
target_replica_node.name
1587-
] = target_replica_node
1585+
tmp_nodes_cache[target_replica_node.name] = (
1586+
target_replica_node
1587+
)
15881588
else:
15891589
# Validate that 2 nodes want to use the same slot cache
15901590
# setup

redis/commands/core.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3399,9 +3399,7 @@ def smembers(self, name: str) -> Union[Awaitable[Set], Set]:
33993399
"""
34003400
return self.execute_command("SMEMBERS", name, keys=[name])
34013401

3402-
def smismember(
3403-
self, name: str, values: List, *args: List
3404-
) -> Union[
3402+
def smismember(self, name: str, values: List, *args: List) -> Union[
34053403
Awaitable[List[Union[Literal[0], Literal[1]]]],
34063404
List[Union[Literal[0], Literal[1]]],
34073405
]:

redis/exceptions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,5 +217,4 @@ class SlotNotCoveredError(RedisClusterException):
217217
pass
218218

219219

220-
class MaxConnectionsError(ConnectionError):
221-
...
220+
class MaxConnectionsError(ConnectionError): ...

redis/typing.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,10 @@
5454
class CommandsProtocol(Protocol):
5555
connection_pool: Union["AsyncConnectionPool", "ConnectionPool"]
5656

57-
def execute_command(self, *args, **options):
58-
...
57+
def execute_command(self, *args, **options): ...
5958

6059

6160
class ClusterCommandsProtocol(CommandsProtocol, Protocol):
6261
encoder: "Encoder"
6362

64-
def execute_command(self, *args, **options) -> Union[Any, Awaitable]:
65-
...
63+
def execute_command(self, *args, **options) -> Union[Any, Awaitable]: ...

tests/test_asyncio/test_pipeline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ async def test_exec_error_in_response(self, r):
117117
assert await pipe.set("z", "zzz").execute() == [True]
118118
assert await r.get("z") == b"zzz"
119119

120+
@skip_if_redis_enterprise()
120121
async def test_exec_error_raised(self, r):
121122
await r.set("c", "a")
122123
async with r.pipeline() as pipe:
@@ -139,7 +140,7 @@ async def test_transaction_with_empty_error_command(self, r):
139140
"""
140141
for error_switch in (True, False):
141142
async with r.pipeline() as pipe:
142-
pipe.set("a", 1).mget([]).set("c", 3)
143+
pipe.set("a", 1).mget([]).set("a", 3)
143144
result = await pipe.execute(raise_on_error=error_switch)
144145

145146
assert result[0]

tests/test_asyncio/test_search.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ async def test_client(decoded_r: redis.Redis):
326326

327327
@pytest.mark.redismod
328328
@pytest.mark.onlynoncluster
329+
@skip_if_redis_enterprise()
329330
async def test_scores(decoded_r: redis.Redis):
330331
await decoded_r.ft().create_index((TextField("txt"),))
331332

@@ -1013,6 +1014,7 @@ async def test_phonetic_matcher(decoded_r: redis.Redis):
10131014

10141015
@pytest.mark.redismod
10151016
@pytest.mark.onlynoncluster
1017+
@skip_if_redis_enterprise()
10161018
async def test_scorer(decoded_r: redis.Redis):
10171019
await decoded_r.ft().create_index((TextField("description"),))
10181020

tests/test_commands.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,7 @@ def test_rpushx(self, r):
21322132

21332133
# SCAN COMMANDS
21342134
@pytest.mark.onlynoncluster
2135+
@skip_if_redis_enterprise()
21352136
@skip_if_server_version_lt("2.8.0")
21362137
def test_scan(self, r):
21372138
r.set("a", 1)
@@ -2144,6 +2145,7 @@ def test_scan(self, r):
21442145
assert set(keys) == {b"a"}
21452146

21462147
@pytest.mark.onlynoncluster
2148+
@skip_if_redis_enterprise()
21472149
@skip_if_server_version_lt("6.0.0")
21482150
def test_scan_type(self, r):
21492151
r.sadd("a-set", 1)

tests/test_function.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import pytest
22
from redis.exceptions import ResponseError
33

4-
from .conftest import assert_resp_response, skip_if_server_version_lt
4+
from .conftest import (
5+
assert_resp_response,
6+
skip_if_redis_enterprise,
7+
skip_if_server_version_lt,
8+
)
59

610
engine = "lua"
711
lib = "mylib"
@@ -51,6 +55,7 @@ def test_function_flush(self, r):
5155
r.function_flush("ABC")
5256

5357
@pytest.mark.onlynoncluster
58+
@skip_if_redis_enterprise()
5459
def test_function_list(self, r):
5560
r.function_load(f"#!{engine} name={lib} \n {function}")
5661
res = [

tests/test_pipeline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def test_exec_error_in_response(self, r):
122122
assert pipe.set("z", "zzz").execute() == [True]
123123
assert r["z"] == b"zzz"
124124

125+
@skip_if_redis_enterprise()
125126
def test_exec_error_raised(self, r):
126127
r["c"] = "a"
127128
with r.pipeline() as pipe:
@@ -144,7 +145,7 @@ def test_transaction_with_empty_error_command(self, r):
144145
"""
145146
for error_switch in (True, False):
146147
with r.pipeline() as pipe:
147-
pipe.set("a", 1).mget([]).set("c", 3)
148+
pipe.set("a", 1).mget([]).set("a", 3)
148149
result = pipe.execute(raise_on_error=error_switch)
149150

150151
assert result[0]

tests/test_search.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ def test_client(client):
311311

312312
@pytest.mark.redismod
313313
@pytest.mark.onlynoncluster
314+
@skip_if_redis_enterprise()
314315
def test_scores(client):
315316
client.ft().create_index((TextField("txt"),))
316317

@@ -931,6 +932,7 @@ def test_phonetic_matcher(client):
931932

932933
@pytest.mark.redismod
933934
@pytest.mark.onlynoncluster
935+
@skip_if_redis_enterprise()
934936
def test_scorer(client):
935937
client.ft().create_index((TextField("description"),))
936938

@@ -1942,6 +1944,7 @@ def test_profile(client):
19421944

19431945
@pytest.mark.redismod
19441946
@pytest.mark.onlynoncluster
1947+
@skip_if_redis_enterprise()
19451948
def test_profile_limited(client):
19461949
client.ft().create_index((TextField("t"),))
19471950
client.ft().client.hset("1", "t", "hello")

0 commit comments

Comments
 (0)