Skip to content

Commit 2901de6

Browse files
committed
Remove deprecated dependency
No need for an external library just for 5 annotations.
1 parent 66c4e60 commit 2901de6

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
@@ -19,6 +19,7 @@
1919
* Fix reusing the old nodes' connections when cluster topology refresh is being done
2020
* Fix RedisCluster to immediately raise AuthenticationError without a retry
2121
* ClusterPipeline Doesn't Handle ConnectionError for Dead Hosts (#2225)
22+
* The `deprecated` library is no longer a dependency
2223

2324
* 4.1.3 (Feb 8, 2022)
2425
* 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"
@@ -324,12 +322,14 @@ def query(self, key, *items):
324322
""" # noqa
325323
return self.execute_command(TOPK_QUERY, key, *items)
326324

327-
@deprecated(version="4.4.0", reason="deprecated since redisbloom 2.4.0")
328325
def count(self, key, *items):
329326
"""
330327
Return count for one `item` or more from `key`.
331328
For more information see `TOPK.COUNT <https://redis.io/commands/topk.count>`_.
332329
""" # noqa
330+
warn_deprecated(
331+
name="count", reason="deprecated since redisbloom 2.4.0", version="4.4.0"
332+
)
333333
return self.execute_command(TOPK_COUNT, key, *items)
334334

335335
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
@@ -79,3 +79,14 @@ def merge_result(command, res):
7979
result.add(value)
8080

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

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
async-timeout>=4.0.2
2-
deprecated>=1.2.3
32
packaging>=20.4
43
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
"packaging>=20.4",
3736
'importlib-metadata >= 1.0; python_version < "3.8"',
3837
'typing-extensions; python_version<"3.8"',

0 commit comments

Comments
 (0)