Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 310813a

Browse files
Annotate deprecated_args decorator to preserve wrapped function type signature (#3701)
1 parent 07b0e2c commit 310813a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

‎redis/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import datetime
22
import logging
33
import textwrap
4+
from collections.abc import Callable
45
from contextlib import contextmanager
56
from functools import wraps
6-
from typing import Any, Dict, List, Mapping, Optional, Union
7+
from typing import Any, Dict, List, Mapping, Optional, TypeVar, Union
78

89
from redis.exceptions import DataError
910
from redis.typing import AbsExpiryT, EncodableT, ExpiryT
@@ -150,18 +151,21 @@ def warn_deprecated_arg_usage(
150151
warnings.warn(msg, category=DeprecationWarning, stacklevel=stacklevel)
151152

152153

154+
C = TypeVar("C", bound=Callable)
155+
156+
153157
def deprecated_args(
154158
args_to_warn: list = ["*"],
155159
allowed_args: list = [],
156160
reason: str = "",
157161
version: str = "",
158-
):
162+
)->Callable[[C], C]:
159163
"""
160164
Decorator to mark specified args of a function as deprecated.
161165
If '*' is in args_to_warn, all arguments will be marked as deprecated.
162166
"""
163167

164-
def decorator(func):
168+
def decorator(func: C) ->C:
165169
@wraps(func)
166170
def wrapper(*args, **kwargs):
167171
# Get function argument names

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /