Skip to content

Commit

Permalink
Remove deprecated dependency (#2386)
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 authored and chayim committed Nov 21, 2022
1 parent 738d0c7 commit d088178
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* Added dynaminc_startup_nodes configuration to RedisCluster
* 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)
* Remove compatibility code for old versions of Hiredis, drop Packaging dependency
* The `deprecated` library is no longer a dependency

* 4.1.3 (Feb 8, 2022)
* Fix flushdb and flushall (#1926)
* Add redis5 and redis4 dockers (#1871)
Expand Down
28 changes: 28 additions & 0 deletions redis/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from contextlib import contextmanager
from functools import wraps
from typing import Any, Dict, Mapping, Union

try:
Expand Down Expand Up @@ -79,3 +80,30 @@ def merge_result(command, res):
result.add(value)

return list(result)


def warn_deprecated(name, reason="", version="", stacklevel=2):
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=stacklevel)


def deprecated_function(reason="", version="", name=None):
"""
Decorator to mark a function as deprecated.
"""

def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
warn_deprecated(name or func.__name__, reason, version, stacklevel=3)
return func(*args, **kwargs)

return wrapper

return decorator
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.6",
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 d088178

Please sign in to comment.