Skip to content

Commit b8aeb71

Browse files
committed
rename kwargs to no underscore for consistency
1 parent d1c25b9 commit b8aeb71

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
@@ -3046,7 +3046,7 @@ def scan_iter(
30463046
match=match,
30473047
count=count,
30483048
_type=_type,
3049-
_iter_req_id=iter_req_id,
3049+
iter_req_id=iter_req_id,
30503050
**kwargs,
30513051
)
30523052
yield from data
@@ -3094,7 +3094,7 @@ def sscan_iter(
30943094
iter_req_id = uuid.uuid4()
30953095
while cursor != 0:
30963096
cursor, data = self.sscan(
3097-
name, cursor=cursor, match=match, count=count, _iter_req_id=iter_req_id
3097+
name, cursor=cursor, match=match, count=count, iter_req_id=iter_req_id
30983098
)
30993099
yield from data
31003100

@@ -3154,7 +3154,7 @@ def hscan_iter(
31543154
match=match,
31553155
count=count,
31563156
no_values=no_values,
3157-
_iter_req_id=iter_req_id,
3157+
iter_req_id=iter_req_id,
31583158
)
31593159
if no_values:
31603160
yield from data
@@ -3216,7 +3216,7 @@ def zscan_iter(
32163216
match=match,
32173217
count=count,
32183218
score_cast_func=score_cast_func,
3219-
_iter_req_id=iter_req_id,
3219+
iter_req_id=iter_req_id,
32203220
)
32213221
yield from data
32223222

@@ -3254,7 +3254,7 @@ async def scan_iter(
32543254
match=match,
32553255
count=count,
32563256
_type=_type,
3257-
_iter_req_id=iter_req_id,
3257+
iter_req_id=iter_req_id,
32583258
**kwargs,
32593259
)
32603260
for d in data:
@@ -3281,7 +3281,7 @@ async def sscan_iter(
32813281
cursor = "0"
32823282
while cursor != 0:
32833283
cursor, data = await self.sscan(
3284-
name, cursor=cursor, match=match, count=count, _iter_req_id=iter_req_id
3284+
name, cursor=cursor, match=match, count=count, iter_req_id=iter_req_id
32853285
)
32863286
for d in data:
32873287
yield d
@@ -3315,7 +3315,7 @@ async def hscan_iter(
33153315
match=match,
33163316
count=count,
33173317
no_values=no_values,
3318-
_iter_req_id=iter_req_id,
3318+
iter_req_id=iter_req_id,
33193319
)
33203320
if no_values:
33213321
for it in data:
@@ -3353,7 +3353,7 @@ async def zscan_iter(
33533353
match=match,
33543354
count=count,
33553355
score_cast_func=score_cast_func,
3356-
_iter_req_id=iter_req_id,
3356+
iter_req_id=iter_req_id,
33573357
)
33583358
for d in data:
33593359
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)