Skip to content

Commit a67c7ba

Browse files
committed
PR suggestions
1 parent 17ed310 commit a67c7ba

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

python/python/glide/async_commands/core.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,14 +2297,15 @@ async def bzpopmax(
22972297
self, keys: List[str], timeout: float
22982298
) -> Optional[List[Union[str, float]]]:
22992299
"""
2300-
Blocks the connection until it removes and returns a member with the highest score from the first non-empty
2301-
sorted set, with the given keys being checked in the order they are provided.
2300+
Pops the member with the highest score from the first non-empty sorted set, with the given keys being checked in
2301+
the order that they are given. Blocks the connection when there are no members to remove from any of the given
2302+
sorted sets.
23022303
23032304
When in cluster mode, all keys must map to the same hash slot.
23042305
2305-
BZPOPMAX is the blocking variant of ZPOPMAX.
2306+
`BZPOPMAX` is the blocking variant of `ZPOPMAX`.
23062307
2307-
BZPOPMAX is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
2308+
`BZPOPMAX` is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
23082309
23092310
See https://valkey.io/commands/bzpopmax for more details.
23102311
@@ -2318,8 +2319,10 @@ async def bzpopmax(
23182319
and the member score. If no member could be popped and the `timeout` expired, returns None.
23192320
23202321
Examples:
2322+
>>> await client.zadd("my_sorted_set1", {"member1": 10.0, "member2": 5.0})
2323+
2 # Two elements have been added to the sorted set at "my_sorted_set1".
23212324
>>> await client.bzpopmax(["my_sorted_set1", "my_sorted_set2"], 0.5)
2322-
['my_sorted_set1', 'member1', 10.0] # 'member1' with a score of 10.0 has been removed from 'my_sorted_set'.
2325+
['my_sorted_set1', 'member1', 10.0] # "member1" with a score of 10.0 has been removed from "my_sorted_set1".
23232326
"""
23242327
return cast(
23252328
Optional[List[Union[str, float]]],
@@ -2362,14 +2365,15 @@ async def bzpopmin(
23622365
self, keys: List[str], timeout: float
23632366
) -> Optional[List[Union[str, float]]]:
23642367
"""
2365-
Blocks the connection until it removes and returns a member with the lowest score from the first non-empty
2366-
sorted set, with the given keys being checked in the order they are provided.
2368+
Pops the member with the lowest score from the first non-empty sorted set, with the given keys being checked in
2369+
the order that they are given. Blocks the connection when there are no members to remove from any of the given
2370+
sorted sets.
23672371
23682372
When in cluster mode, all keys must map to the same hash slot.
23692373
2370-
BZPOPMIN is the blocking variant of ZPOPMIN.
2374+
`BZPOPMIN` is the blocking variant of `ZPOPMIN`.
23712375
2372-
BZPOPMIN is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
2376+
`BZPOPMIN` is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
23732377
23742378
See https://valkey.io/commands/bzpopmin for more details.
23752379
@@ -2383,8 +2387,10 @@ async def bzpopmin(
23832387
and the member score. If no member could be popped and the `timeout` expired, returns None.
23842388
23852389
Examples:
2390+
>>> await client.zadd("my_sorted_set1", {"member1": 10.0, "member2": 5.0})
2391+
2 # Two elements have been added to the sorted set at "my_sorted_set1".
23862392
>>> await client.bzpopmin(["my_sorted_set1", "my_sorted_set2"], 0.5)
2387-
['my_sorted_set1', 'member1', 1.0] # 'member1' with a score of 1.0 has been removed from 'my_sorted_set'.
2393+
['my_sorted_set1', 'member2', 5.0] # "member2" with a score of 5.0 has been removed from "my_sorted_set1".
23882394
"""
23892395
return cast(
23902396
Optional[List[Union[str, float]]],

python/python/glide/async_commands/transaction.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,12 +1628,13 @@ def zpopmax(
16281628

16291629
def bzpopmax(self: TTransaction, keys: List[str], timeout: float) -> TTransaction:
16301630
"""
1631-
Blocks the connection until it removes and returns a member with the highest score from the first non-empty
1632-
sorted set, with the given keys being checked in the order they are provided.
1631+
Pops the member with the highest score from the first non-empty sorted set, with the given keys being checked in
1632+
the order that they are given. Blocks the connection when there are no members to remove from any of the given
1633+
sorted sets.
16331634
1634-
BZPOPMAX is the blocking variant of ZPOPMAX.
1635+
`BZPOPMAX` is the blocking variant of `ZPOPMAX`.
16351636
1636-
BZPOPMAX is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
1637+
`BZPOPMAX` is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
16371638
16381639
See https://valkey.io/commands/bzpopmax for more details.
16391640
@@ -1673,12 +1674,13 @@ def zpopmin(
16731674

16741675
def bzpopmin(self: TTransaction, keys: List[str], timeout: float) -> TTransaction:
16751676
"""
1676-
Blocks the connection until it removes and returns a member with the lowest score from the first non-empty
1677-
sorted set, with the given keys being checked in the order they are provided.
1677+
Pops the member with the lowest score from the first non-empty sorted set, with the given keys being checked in
1678+
the order that they are given. Blocks the connection when there are no members to remove from any of the given
1679+
sorted sets.
16781680
1679-
BZPOPMIN is the blocking variant of ZPOPMIN.
1681+
`BZPOPMIN` is the blocking variant of `ZPOPMIN`.
16801682
1681-
BZPOPMIN is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
1683+
`BZPOPMIN` is a client blocking command, see https://github.com/aws/glide-for-redis/wiki/General-Concepts#blocking-commands for more details and best practices.
16821684
16831685
See https://valkey.io/commands/bzpopmin for more details.
16841686

python/python/tests/test_async_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,6 +1904,10 @@ async def test_bzpopmin(self, redis_client: TRedisClient):
19041904
]
19051905
assert await redis_client.bzpopmin(["non_existing_key"], 0.5) is None
19061906

1907+
# invalid argument - key list must not be empty
1908+
with pytest.raises(RequestError):
1909+
await redis_client.bzpopmin([], 0.5)
1910+
19071911
# key exists, but it is not a sorted set
19081912
assert await redis_client.set("foo", "value") == OK
19091913
with pytest.raises(RequestError):
@@ -1955,6 +1959,10 @@ async def test_bzpopmax(self, redis_client: TRedisClient):
19551959
]
19561960
assert await redis_client.bzpopmax(["non_existing_key"], 0.5) is None
19571961

1962+
# invalid argument - key list must not be empty
1963+
with pytest.raises(RequestError):
1964+
await redis_client.bzpopmax([], 0.5)
1965+
19581966
# key exists, but it is not a sorted set
19591967
assert await redis_client.set("foo", "value") == OK
19601968
with pytest.raises(RequestError):

0 commit comments

Comments
 (0)