Skip to content

Commit f8814da

Browse files
committed
Remove deprecated dependency
No need for an external library just for 5 annotations.
1 parent 7c6a812 commit f8814da

File tree

6 files changed

+35
-18
lines changed

6 files changed

+35
-18
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* Fix RedisCluster to immediately raise AuthenticationError without a retry
2121
* ClusterPipeline Doesn't Handle ConnectionError for Dead Hosts (#2225)
2222
* Remove compatibility code for old versions of Hiredis, drop Packaging dependency
23+
* The `deprecated` library is no longer a dependency
2324

2425
* 4.1.3 (Feb 8, 2022)
2526
* Fix flushdb and flushall (#1926)

redis/commands/bf/commands.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
from deprecated import deprecated
2-
31
from redis.client import NEVER_DECODE
42
from redis.exceptions import ModuleError
5-
from redis.utils import HIREDIS_AVAILABLE
3+
from redis.utils import HIREDIS_AVAILABLE, warn_deprecated
64

75
BF_RESERVE = "BF.RESERVE"
86
BF_ADD = "BF.ADD"
@@ -327,12 +325,14 @@ def query(self, key, *items):
327325
""" # noqa
328326
return self.execute_command(TOPK_QUERY, key, *items)
329327

330-
@deprecated(version="4.4.0", reason="deprecated since redisbloom 2.4.0")
331328
def count(self, key, *items):
332329
"""
333330
Return count for one `item` or more from `key`.
334331
For more information see `TOPK.COUNT <https://redis.io/commands/topk.count>`_.
335332
""" # noqa
333+
warn_deprecated(
334+
name="count", reason="deprecated since redisbloom 2.4.0", version="4.4.0"
335+
)
336336
return self.execute_command(TOPK_COUNT, key, *items)
337337

338338
def list(self, key, withcount=False):

redis/commands/json/commands.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
from json import JSONDecodeError, loads
33
from typing import Dict, List, Optional, Union
44

5-
from deprecated import deprecated
6-
75
from redis.exceptions import DataError
6+
from redis.utils import warn_deprecated
87

98
from ._util import JsonType
109
from .decoders import decode_dict_keys
@@ -137,13 +136,15 @@ def numincrby(self, name: str, path: str, number: int) -> str:
137136
"JSON.NUMINCRBY", name, str(path), self._encode(number)
138137
)
139138

140-
@deprecated(version="4.0.0", reason="deprecated since redisjson 1.0.0")
141139
def nummultby(self, name: str, path: str, number: int) -> str:
142140
"""Multiply the numeric (integer or floating point) JSON value under
143141
``path`` at key ``name`` with the provided ``number``.
144142
145143
For more information see `JSON.NUMMULTBY <https://redis.io/commands/json.nummultby>`_.
146144
""" # noqa
145+
warn_deprecated(
146+
name="nummultby", reason="deprecated since redisjson 1.0.0", version="4.0.0"
147+
)
147148
return self.execute_command(
148149
"JSON.NUMMULTBY", name, str(path), self._encode(number)
149150
)
@@ -368,20 +369,26 @@ def debug(
368369
pieces.append(str(path))
369370
return self.execute_command("JSON.DEBUG", *pieces)
370371

371-
@deprecated(
372-
version="4.0.0", reason="redisjson-py supported this, call get directly."
373-
)
374372
def jsonget(self, *args, **kwargs):
373+
warn_deprecated(
374+
name="jsonget",
375+
reason="redisjson-py supported this, call get directly.",
376+
version="4.0.0",
377+
)
375378
return self.get(*args, **kwargs)
376379

377-
@deprecated(
378-
version="4.0.0", reason="redisjson-py supported this, call get directly."
379-
)
380380
def jsonmget(self, *args, **kwargs):
381+
warn_deprecated(
382+
name="jsonmget",
383+
reason="redisjson-py supported this, call get directly.",
384+
version="4.0.0",
385+
)
381386
return self.mget(*args, **kwargs)
382387

383-
@deprecated(
384-
version="4.0.0", reason="redisjson-py supported this, call get directly."
385-
)
386388
def jsonset(self, *args, **kwargs):
389+
warn_deprecated(
390+
name="jsonset",
391+
reason="redisjson-py supported this, call get directly.",
392+
version="4.0.0",
393+
)
387394
return self.set(*args, **kwargs)

redis/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,14 @@ def merge_result(command, res):
8080
result.add(value)
8181

8282
return list(result)
83+
84+
85+
def warn_deprecated(name, reason="", version=""):
86+
import warnings
87+
88+
msg = f"Call to deprecated {name}."
89+
if reason:
90+
msg += f" ({reason})"
91+
if version:
92+
msg += f" -- Deprecated since version {version}."
93+
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
async-timeout>=4.0.2
2-
deprecated>=1.2.3
32
typing-extensions; python_version<"3.8"

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
author_email="[email protected]",
3333
python_requires=">=3.7",
3434
install_requires=[
35-
"deprecated>=1.2.3",
3635
'importlib-metadata >= 1.0; python_version < "3.8"',
3736
'typing-extensions; python_version<"3.8"',
3837
"async-timeout>=4.0.2",

0 commit comments

Comments
 (0)