Skip to content

Commit 3db5e5e

Browse files
committed
Mark TOPK.COUNT as deprecated (#2363)
* deprecate * linters
1 parent 7325ccd commit 3db5e5e

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

redis/commands/bf/commands.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from deprecated import deprecated
2+
13
from redis.client import NEVER_DECODE
24
from redis.exceptions import ModuleError
35
from redis.utils import HIREDIS_AVAILABLE
@@ -322,6 +324,7 @@ def query(self, key, *items):
322324
""" # noqa
323325
return self.execute_command(TOPK_QUERY, key, *items)
324326

327+
@deprecated(version="4.4.0", reason="deprecated since redisbloom 2.4.0")
325328
def count(self, key, *items):
326329
"""
327330
Return count for one `item` or more from `key`.

tests/test_asyncio/test_bloom.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,10 @@ async def test_topk(modclient: redis.Redis):
265265
assert [1, 1, 0, 0, 1, 0, 0] == await modclient.topk().query(
266266
"topk", "A", "B", "C", "D", "E", "F", "G"
267267
)
268-
assert [4, 3, 2, 3, 3, 0, 1] == await modclient.topk().count(
269-
"topk", "A", "B", "C", "D", "E", "F", "G"
270-
)
268+
with pytest.deprecated_call():
269+
assert [4, 3, 2, 3, 3, 0, 1] == await modclient.topk().count(
270+
"topk", "A", "B", "C", "D", "E", "F", "G"
271+
)
271272

272273
# test full list
273274
assert await modclient.topk().reserve("topklist", 3, 50, 3, 0.9)
@@ -309,9 +310,10 @@ async def test_topk_incrby(modclient: redis.Redis):
309310
)
310311
res = await modclient.topk().incrby("topk", ["42", "xyzzy"], [8, 4])
311312
assert [None, "bar"] == res
312-
assert [3, 6, 10, 4, 0] == await modclient.topk().count(
313-
"topk", "bar", "baz", "42", "xyzzy", 4
314-
)
313+
with pytest.deprecated_call():
314+
assert [3, 6, 10, 4, 0] == await modclient.topk().count(
315+
"topk", "bar", "baz", "42", "xyzzy", 4
316+
)
315317

316318

317319
# region Test T-Digest

tests/test_bloom.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,10 @@ def test_topk(client):
280280
assert [1, 1, 0, 0, 1, 0, 0] == client.topk().query(
281281
"topk", "A", "B", "C", "D", "E", "F", "G"
282282
)
283-
assert [4, 3, 2, 3, 3, 0, 1] == client.topk().count(
284-
"topk", "A", "B", "C", "D", "E", "F", "G"
285-
)
283+
with pytest.deprecated_call():
284+
assert [4, 3, 2, 3, 3, 0, 1] == client.topk().count(
285+
"topk", "A", "B", "C", "D", "E", "F", "G"
286+
)
286287

287288
# test full list
288289
assert client.topk().reserve("topklist", 3, 50, 3, 0.9)
@@ -322,9 +323,10 @@ def test_topk_incrby(client):
322323
"topk", ["bar", "baz", "42"], [3, 6, 2]
323324
)
324325
assert [None, "bar"] == client.topk().incrby("topk", ["42", "xyzzy"], [8, 4])
325-
assert [3, 6, 10, 4, 0] == client.topk().count(
326-
"topk", "bar", "baz", "42", "xyzzy", 4
327-
)
326+
with pytest.deprecated_call():
327+
assert [3, 6, 10, 4, 0] == client.topk().count(
328+
"topk", "bar", "baz", "42", "xyzzy", 4
329+
)
328330

329331

330332
# region Test T-Digest

0 commit comments

Comments
 (0)