Skip to content

Commit

Permalink
Remove deprecated dependency
Browse files Browse the repository at this point in the history
No need for an external library just for 5 annotations.
  • Loading branch information
akx committed Sep 19, 2022
1 parent 66c4e60 commit 2901de6
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Fix reusing the old nodes' connections when cluster topology refresh is being done
* Fix RedisCluster to immediately raise AuthenticationError without a retry
* ClusterPipeline Doesn't Handle ConnectionError for Dead Hosts (#2225)
* The `deprecated` library is no longer a dependency

* 4.1.3 (Feb 8, 2022)
* Fix flushdb and flushall (#1926)
Expand Down
8 changes: 4 additions & 4 deletions redis/commands/bf/commands.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from deprecated import deprecated

from redis.client import NEVER_DECODE
from redis.exceptions import ModuleError
from redis.utils import HIREDIS_AVAILABLE
from redis.utils import HIREDIS_AVAILABLE, warn_deprecated

BF_RESERVE = "BF.RESERVE"
BF_ADD = "BF.ADD"
Expand Down Expand Up @@ -324,12 +322,14 @@ def query(self, key, *items):
""" # noqa
return self.execute_command(TOPK_QUERY, key, *items)

@deprecated(version="4.4.0", reason="deprecated since redisbloom 2.4.0")
def count(self, key, *items):
"""
Return count for one `item` or more from `key`.
For more information see `TOPK.COUNT <https://redis.io/commands/topk.count>`_.
""" # noqa
warn_deprecated(
name="count", reason="deprecated since redisbloom 2.4.0", version="4.4.0"
)
return self.execute_command(TOPK_COUNT, key, *items)

def list(self, key, withcount=False):
Expand Down
31 changes: 19 additions & 12 deletions redis/commands/json/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from json import JSONDecodeError, loads
from typing import Dict, List, Optional, Union

from deprecated import deprecated

from redis.exceptions import DataError
from redis.utils import warn_deprecated

from ._util import JsonType
from .decoders import decode_dict_keys
Expand Down Expand Up @@ -137,13 +136,15 @@ def numincrby(self, name: str, path: str, number: int) -> str:
"JSON.NUMINCRBY", name, str(path), self._encode(number)
)

@deprecated(version="4.0.0", reason="deprecated since redisjson 1.0.0")
def nummultby(self, name: str, path: str, number: int) -> str:
"""Multiply the numeric (integer or floating point) JSON value under
``path`` at key ``name`` with the provided ``number``.
For more information see `JSON.NUMMULTBY <https://redis.io/commands/json.nummultby>`_.
""" # noqa
warn_deprecated(
name="nummultby", reason="deprecated since redisjson 1.0.0", version="4.0.0"
)
return self.execute_command(
"JSON.NUMMULTBY", name, str(path), self._encode(number)
)
Expand Down Expand Up @@ -368,20 +369,26 @@ def debug(
pieces.append(str(path))
return self.execute_command("JSON.DEBUG", *pieces)

@deprecated(
version="4.0.0", reason="redisjson-py supported this, call get directly."
)
def jsonget(self, *args, **kwargs):
warn_deprecated(
name="jsonget",
reason="redisjson-py supported this, call get directly.",
version="4.0.0",
)
return self.get(*args, **kwargs)

@deprecated(
version="4.0.0", reason="redisjson-py supported this, call get directly."
)
def jsonmget(self, *args, **kwargs):
warn_deprecated(
name="jsonmget",
reason="redisjson-py supported this, call get directly.",
version="4.0.0",
)
return self.mget(*args, **kwargs)

@deprecated(
version="4.0.0", reason="redisjson-py supported this, call get directly."
)
def jsonset(self, *args, **kwargs):
warn_deprecated(
name="jsonset",
reason="redisjson-py supported this, call get directly.",
version="4.0.0",
)
return self.set(*args, **kwargs)
11 changes: 11 additions & 0 deletions redis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,14 @@ def merge_result(command, res):
result.add(value)

return list(result)


def warn_deprecated(name, reason="", version=""):
import warnings

msg = f"Call to deprecated {name}."
if reason:
msg += f" ({reason})"
if version:
msg += f" -- Deprecated since version {version}."
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
async-timeout>=4.0.2
deprecated>=1.2.3
packaging>=20.4
typing-extensions; python_version<"3.8"
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
author_email="oss@redis.com",
python_requires=">=3.7",
install_requires=[
"deprecated>=1.2.3",
"packaging>=20.4",
'importlib-metadata >= 1.0; python_version < "3.8"',
'typing-extensions; python_version<"3.8"',
Expand Down

0 comments on commit 2901de6

Please sign in to comment.