Skip to content

Commit d088178

Browse files
akxchayim
authored andcommitted
Remove deprecated dependency (#2386)
No need for an external library just for 5 annotations.
1 parent 738d0c7 commit d088178

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
* Added dynaminc_startup_nodes configuration to RedisCluster
1515
* Fix reusing the old nodes' connections when cluster topology refresh is being done
1616
* Fix RedisCluster to immediately raise AuthenticationError without a retry
17+
* ClusterPipeline Doesn't Handle ConnectionError for Dead Hosts (#2225)
18+
* Remove compatibility code for old versions of Hiredis, drop Packaging dependency
19+
* The `deprecated` library is no longer a dependency
20+
1721
* 4.1.3 (Feb 8, 2022)
1822
* Fix flushdb and flushall (#1926)
1923
* Add redis5 and redis4 dockers (#1871)

redis/utils.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from contextlib import contextmanager
2+
from functools import wraps
23
from typing import Any, Dict, Mapping, Union
34

45
try:
@@ -79,3 +80,30 @@ def merge_result(command, res):
7980
result.add(value)
8081

8182
return list(result)
83+
84+
85+
def warn_deprecated(name, reason="", version="", stacklevel=2):
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=stacklevel)
94+
95+
96+
def deprecated_function(reason="", version="", name=None):
97+
"""
98+
Decorator to mark a function as deprecated.
99+
"""
100+
101+
def decorator(func):
102+
@wraps(func)
103+
def wrapper(*args, **kwargs):
104+
warn_deprecated(name or func.__name__, reason, version, stacklevel=3)
105+
return func(*args, **kwargs)
106+
107+
return wrapper
108+
109+
return decorator

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.6",
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)