Skip to content

Commit 8e03127

Browse files
committed
Replacing usage of reduce in the boolean return types with python's built-in 'all' function for better performance and improved readability.
1 parent 0cfcb58 commit 8e03127

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

redis/_parsers/resp3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from typing import Any, Union
33

44
from ..exceptions import ConnectionError, InvalidResponse, ResponseError
5-
from ..typing import EncodableT
65
from ..notifications import NodeReplacementNotification
6+
from ..typing import EncodableT
77
from .base import (
88
AsyncPushNotificationsParser,
99
PushNotificationsParser,

redis/asyncio/sentinel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import asyncio
22
import random
33
import weakref
4-
from functools import reduce
54
from typing import AsyncIterator, Iterable, Mapping, Optional, Sequence, Tuple, Type
65

76
from redis.asyncio.client import Redis
@@ -248,7 +247,7 @@ async def execute_command(self, *args, **kwargs):
248247
if return_responses:
249248
return responses
250249

251-
return bool(reduce(lambda x, y: x and y, responses))
250+
return all(responses)
252251

253252
def __repr__(self):
254253
sentinel_addresses = []

redis/sentinel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import random
22
import weakref
3-
from functools import reduce
43
from typing import Optional
54

65
from redis.client import Redis
@@ -275,7 +274,7 @@ def execute_command(self, *args, **kwargs):
275274
if return_responses:
276275
return responses
277276

278-
return bool(reduce(lambda x, y: x and y, responses))
277+
return all(responses)
279278

280279
def __repr__(self):
281280
sentinel_addresses = []

0 commit comments

Comments
 (0)