Skip to content

Commit 1c88dc8

Browse files
committed
rename kwargs to no underscore for consistency
1 parent 436cce8 commit 1c88dc8

File tree

7 files changed

+45
-45
lines changed

7 files changed

+45
-45
lines changed

redis/asyncio/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ async def execute_command(self, *args, **options):
652652
if not self.connection:
653653
await pool.release(conn)
654654
if "ITER" in command_name.upper():
655-
pool.cleanup(iter_req_id=options.get("_iter_req_id", None))
655+
pool.cleanup(iter_req_id=options.get("iter_req_id", None))
656656

657657
async def parse_response(
658658
self, connection: Connection, command_name: Union[str, bytes], **options

redis/asyncio/sentinel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def cleanup(self, **options):
230230
Remove the SCAN ITER family command's request id from the dictionary
231231
"""
232232
self._iter_req_id_to_replica_address.pop(
233-
options.get("_iter_req_id", None), None
233+
options.get("iter_req_id", None), None
234234
)
235235

236236
async def get_connection(
@@ -250,7 +250,7 @@ async def get_connection(
250250
should go to the same replica.
251251
"""
252252
# If not an iter command or in master mode, call superclass' implementation
253-
if not (iter_req_id := options.get("_iter_req_id", None)) or self.is_master:
253+
if not (iter_req_id := options.get("iter_req_id", None)) or self.is_master:
254254
return await super().get_connection(command_name, *keys, **options)
255255

256256
# Check if this iter request has already been directed to a particular server

redis/commands/core.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3048,7 +3048,7 @@ def scan_iter(
30483048
match=match,
30493049
count=count,
30503050
_type=_type,
3051-
_iter_req_id=iter_req_id,
3051+
iter_req_id=iter_req_id,
30523052
**kwargs,
30533053
)
30543054
yield from data
@@ -3096,7 +3096,7 @@ def sscan_iter(
30963096
iter_req_id = uuid.uuid4()
30973097
while cursor != 0:
30983098
cursor, data = self.sscan(
3099-
name, cursor=cursor, match=match, count=count, _iter_req_id=iter_req_id
3099+
name, cursor=cursor, match=match, count=count, iter_req_id=iter_req_id
31003100
)
31013101
yield from data
31023102

@@ -3156,7 +3156,7 @@ def hscan_iter(
31563156
match=match,
31573157
count=count,
31583158
no_values=no_values,
3159-
_iter_req_id=iter_req_id,
3159+
iter_req_id=iter_req_id,
31603160
)
31613161
if no_values:
31623162
yield from data
@@ -3218,7 +3218,7 @@ def zscan_iter(
32183218
match=match,
32193219
count=count,
32203220
score_cast_func=score_cast_func,
3221-
_iter_req_id=iter_req_id,
3221+
iter_req_id=iter_req_id,
32223222
)
32233223
yield from data
32243224

@@ -3256,7 +3256,7 @@ async def scan_iter(
32563256
match=match,
32573257
count=count,
32583258
_type=_type,
3259-
_iter_req_id=iter_req_id,
3259+
iter_req_id=iter_req_id,
32603260
**kwargs,
32613261
)
32623262
for d in data:
@@ -3283,7 +3283,7 @@ async def sscan_iter(
32833283
cursor = "0"
32843284
while cursor != 0:
32853285
cursor, data = await self.sscan(
3286-
name, cursor=cursor, match=match, count=count, _iter_req_id=iter_req_id
3286+
name, cursor=cursor, match=match, count=count, iter_req_id=iter_req_id
32873287
)
32883288
for d in data:
32893289
yield d
@@ -3317,7 +3317,7 @@ async def hscan_iter(
33173317
match=match,
33183318
count=count,
33193319
no_values=no_values,
3320-
_iter_req_id=iter_req_id,
3320+
iter_req_id=iter_req_id,
33213321
)
33223322
if no_values:
33233323
for it in data:
@@ -3355,7 +3355,7 @@ async def zscan_iter(
33553355
match=match,
33563356
count=count,
33573357
score_cast_func=score_cast_func,
3358-
_iter_req_id=iter_req_id,
3358+
iter_req_id=iter_req_id,
33593359
)
33603360
for d in data:
33613361
yield d

redis/sentinel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def cleanup(self, **options):
263263
"""
264264
breakpoint()
265265
self._iter_req_id_to_replica_address.pop(
266-
options.get("_iter_req_id", None), None
266+
options.get("iter_req_id", None), None
267267
)
268268

269269
def get_connection(
@@ -283,7 +283,7 @@ def get_connection(
283283
should go to the same replica.
284284
"""
285285
# If not an iter command or in master mode, call superclass' implementation
286-
if not (iter_req_id := options.get("_iter_req_id", None)) or self.is_master:
286+
if not (iter_req_id := options.get("iter_req_id", None)) or self.is_master:
287287
return super().get_connection(command_name, *keys, **options)
288288

289289
# Check if this iter request has already been directed to a particular server

tests/test_asyncio/test_commands.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,8 +1402,8 @@ async def test_zscan_iter(self, r: redis.Redis):
14021402
pairs = [k async for k in r.zscan_iter("a", match="a")]
14031403
assert set(pairs) == {(b"a", 1)}
14041404

1405-
async def test_scan_iter_family_executes_commands_with_same_iter_req_id(self):
1406-
"""Assert that all calls to execute_command receives the _iter_req_id kwarg"""
1405+
async def test_scan_iter_family_executes_commands_with_sameiter_req_id(self):
1406+
"""Assert that all calls to execute_command receives the iter_req_id kwarg"""
14071407
import uuid
14081408

14091409
from redis.commands.core import AsyncScanCommands
@@ -1416,10 +1416,10 @@ async def test_scan_iter_family_executes_commands_with_same_iter_req_id(self):
14161416
uuid, "uuid4", return_value="uuid"
14171417
):
14181418
[a async for a in AsyncScanCommands().scan_iter()]
1419-
mock_execute_command.assert_called_with("SCAN", "0", _iter_req_id="uuid")
1419+
mock_execute_command.assert_called_with("SCAN", "0", iter_req_id="uuid")
14201420
[a async for a in AsyncScanCommands().sscan_iter("")]
14211421
mock_execute_command.assert_called_with(
1422-
"SSCAN", "", "0", _iter_req_id="uuid"
1422+
"SSCAN", "", "0", iter_req_id="uuid"
14231423
)
14241424
with mock.patch.object(
14251425
AsyncScanCommands, "execute_command", mock.AsyncMock(return_value=(0, {}))
@@ -1428,11 +1428,11 @@ async def test_scan_iter_family_executes_commands_with_same_iter_req_id(self):
14281428
):
14291429
[a async for a in AsyncScanCommands().hscan_iter("")]
14301430
mock_execute_command.assert_called_with(
1431-
"HSCAN", "", "0", no_values=None, _iter_req_id="uuid"
1431+
"HSCAN", "", "0", no_values=None, iter_req_id="uuid"
14321432
)
14331433
[a async for a in AsyncScanCommands().zscan_iter("")]
14341434
mock_execute_command.assert_called_with(
1435-
"ZSCAN", "", "0", score_cast_func=mock.ANY, _iter_req_id="uuid"
1435+
"ZSCAN", "", "0", score_cast_func=mock.ANY, iter_req_id="uuid"
14361436
)
14371437

14381438
# SET COMMANDS

tests/test_asyncio/test_sentinel_managed_connection.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ async def test_connects_to_same_address_if_same_id_replica(
124124
connection_pool_replica_mock: SentinelConnectionPool,
125125
) -> None:
126126
"""
127-
Assert that the connection address is the same if the ``_iter_req_id`` is the same
127+
Assert that the connection address is the same if the ``iter_req_id`` is the same
128128
when we are in replica mode using a
129129
:py:class:`~redis.asyncio.sentinel.SentinelConnectionPool`.
130130
"""
131131
connection_for_req_1 = await connection_pool_replica_mock.get_connection(
132-
"ANY", _iter_req_id=1
132+
"ANY", iter_req_id=1
133133
)
134134
assert same_address(
135-
await connection_pool_replica_mock.get_connection("ANY", _iter_req_id=1),
135+
await connection_pool_replica_mock.get_connection("ANY", iter_req_id=1),
136136
connection_for_req_1,
137137
)
138138

@@ -141,32 +141,32 @@ async def test_connects_to_same_conn_object_if_same_id_and_conn_released_replica
141141
connection_pool_replica_mock: SentinelConnectionPool,
142142
) -> None:
143143
"""
144-
Assert that the connection object is the same if the ``_iter_req_id`` is the same
144+
Assert that the connection object is the same if the ``iter_req_id`` is the same
145145
when we are in replica mode using a
146146
:py:class:`~redis.asyncio.sentinel.SentinelConnectionPool`
147147
and if we release the connection back to the connection pool before
148148
trying to connect again.
149149
"""
150150
connection_for_req_1 = await connection_pool_replica_mock.get_connection(
151-
"ANY", _iter_req_id=1
151+
"ANY", iter_req_id=1
152152
)
153153
await connection_pool_replica_mock.release(connection_for_req_1)
154154
assert (
155-
await connection_pool_replica_mock.get_connection("ANY", _iter_req_id=1)
155+
await connection_pool_replica_mock.get_connection("ANY", iter_req_id=1)
156156
== connection_for_req_1
157157
)
158158

159159

160-
async def test_connects_to_diff_address_if_no_iter_req_id_replica(
160+
async def test_connects_to_diff_address_if_noiter_req_id_replica(
161161
connection_pool_replica_mock: SentinelConnectionPool,
162162
) -> None:
163163
"""
164-
Assert that the connection object is different if no _iter_req_id is supplied.
164+
Assert that the connection object is different if no iter_req_id is supplied.
165165
In reality, they can be the same, but in this case, we're not
166166
releasing the connection to the pool so they should always be different.
167167
"""
168168
connection_for_req_1 = await connection_pool_replica_mock.get_connection(
169-
"ANY", _iter_req_id=1
169+
"ANY", iter_req_id=1
170170
)
171171
connection_for_random_req = await connection_pool_replica_mock.get_connection(
172172
"ANYY"
@@ -182,43 +182,43 @@ async def test_connects_to_diff_address_if_no_iter_req_id_replica(
182182
)
183183

184184

185-
async def test_connects_to_same_address_if_same_iter_req_id_master(
185+
async def test_connects_to_same_address_if_sameiter_req_id_master(
186186
connection_pool_master_mock: SentinelConnectionPool,
187187
) -> None:
188188
"""
189-
Assert that the connection address is the same if the ``_iter_req_id`` is the same
189+
Assert that the connection address is the same if the ``iter_req_id`` is the same
190190
when we are in master mode using a
191191
:py:class:`~redis.asyncio.sentinel.SentinelConnectionPool`.
192192
"""
193193
connection_for_req_1 = await connection_pool_master_mock.get_connection(
194-
"ANY", _iter_req_id=1
194+
"ANY", iter_req_id=1
195195
)
196196
assert same_address(
197-
await connection_pool_master_mock.get_connection("ANY", _iter_req_id=1),
197+
await connection_pool_master_mock.get_connection("ANY", iter_req_id=1),
198198
connection_for_req_1,
199199
)
200200

201201

202-
async def test_connects_to_same_conn_object_if_same_iter_req_id_and_released_master(
202+
async def test_connects_to_same_conn_object_if_sameiter_req_id_and_released_master(
203203
connection_pool_master_mock: SentinelConnectionPool,
204204
) -> None:
205205
"""
206-
Assert that the connection address is the same if the ``_iter_req_id`` is the same
206+
Assert that the connection address is the same if the ``iter_req_id`` is the same
207207
when we are in master mode using a
208208
:py:class:`~redis.asyncio.sentinel.SentinelConnectionPool`
209209
and if we release the connection back to the connection pool before
210210
trying to connect again.
211211
"""
212212
connection_for_req_1 = await connection_pool_master_mock.get_connection(
213-
"ANY", _iter_req_id=1
213+
"ANY", iter_req_id=1
214214
)
215215
assert same_address(
216-
await connection_pool_master_mock.get_connection("ANY", _iter_req_id=1),
216+
await connection_pool_master_mock.get_connection("ANY", iter_req_id=1),
217217
connection_for_req_1,
218218
)
219219

220220

221-
async def test_connects_to_same_address_if_no_iter_req_id_master(
221+
async def test_connects_to_same_address_if_noiter_req_id_master(
222222
connection_pool_master_mock: SentinelConnectionPool,
223223
) -> None:
224224
"""
@@ -228,7 +228,7 @@ async def test_connects_to_same_address_if_no_iter_req_id_master(
228228
:py:class:`~redis.asyncio.sentinel.SentinelConnectionPool`.
229229
"""
230230
connection_for_req_1 = await connection_pool_master_mock.get_connection(
231-
"ANY", _iter_req_id=1
231+
"ANY", iter_req_id=1
232232
)
233233
connection_for_random_req = await connection_pool_master_mock.get_connection("ANYY")
234234
assert same_address(connection_for_random_req, connection_for_req_1)
@@ -252,4 +252,4 @@ async def test_scan_iter_family_cleans_up(
252252
r = Redis(connection_pool=connection_pool_replica_mock)
253253

254254
[k async for k in r.scan_iter("a")]
255-
assert not connection_pool_replica_mock._iter_req_id_to_replica_address
255+
assert not connection_pool_replica_mock.iter_req_id_to_replica_address

tests/test_commands.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,8 +2235,8 @@ def test_zscan_iter(self, r):
22352235
pairs = list(r.zscan_iter("a", match="a"))
22362236
assert set(pairs) == {(b"a", 1)}
22372237

2238-
def test_scan_iter_family_executes_commands_with_same_iter_req_id(self):
2239-
"""Assert that all calls to execute_command receives the _iter_req_id kwarg"""
2238+
def test_scan_iter_family_executes_commands_with_sameiter_req_id(self):
2239+
"""Assert that all calls to execute_command receives the iter_req_id kwarg"""
22402240
import uuid
22412241

22422242
from redis.commands.core import ScanCommands
@@ -2247,10 +2247,10 @@ def test_scan_iter_family_executes_commands_with_same_iter_req_id(self):
22472247
uuid, "uuid4", return_value="uuid"
22482248
):
22492249
[a for a in ScanCommands().scan_iter()]
2250-
mock_execute_command.assert_called_with("SCAN", "0", _iter_req_id="uuid")
2250+
mock_execute_command.assert_called_with("SCAN", "0", iter_req_id="uuid")
22512251
[a for a in ScanCommands().sscan_iter("")]
22522252
mock_execute_command.assert_called_with(
2253-
"SSCAN", "", "0", _iter_req_id="uuid"
2253+
"SSCAN", "", "0", iter_req_id="uuid"
22542254
)
22552255
with mock.patch.object(
22562256
ScanCommands, "execute_command", mock.Mock(return_value=(0, {}))
@@ -2259,11 +2259,11 @@ def test_scan_iter_family_executes_commands_with_same_iter_req_id(self):
22592259
):
22602260
[a for a in ScanCommands().hscan_iter("")]
22612261
mock_execute_command.assert_called_with(
2262-
"HSCAN", "", "0", no_values=None, _iter_req_id="uuid"
2262+
"HSCAN", "", "0", no_values=None, iter_req_id="uuid"
22632263
)
22642264
[a for a in ScanCommands().zscan_iter("")]
22652265
mock_execute_command.assert_called_with(
2266-
"ZSCAN", "", "0", score_cast_func=mock.ANY, _iter_req_id="uuid"
2266+
"ZSCAN", "", "0", score_cast_func=mock.ANY, iter_req_id="uuid"
22672267
)
22682268

22692269
# SET COMMANDS

0 commit comments

Comments
 (0)