|
1 | 1 | import datetime
|
2 | 2 | import logging
|
3 | 3 | import textwrap
|
| 4 | +from collections.abc import Callable |
4 | 5 | from contextlib import contextmanager
|
5 | 6 | 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 |
7 | 8 |
|
8 | 9 | from redis.exceptions import DataError
|
9 | 10 | from redis.typing import AbsExpiryT, EncodableT, ExpiryT
|
@@ -150,18 +151,21 @@ def warn_deprecated_arg_usage(
|
150 | 151 | warnings.warn(msg, category=DeprecationWarning, stacklevel=stacklevel)
|
151 | 152 |
|
152 | 153 |
|
| 154 | +C = TypeVar("C", bound=Callable) |
| 155 | + |
| 156 | + |
153 | 157 | def deprecated_args(
|
154 | 158 | args_to_warn: list = ["*"],
|
155 | 159 | allowed_args: list = [],
|
156 | 160 | reason: str = "",
|
157 | 161 | version: str = "",
|
158 | | -): |
| 162 | +)->Callable[[C], C]: |
159 | 163 | """
|
160 | 164 | Decorator to mark specified args of a function as deprecated.
|
161 | 165 | If '*' is in args_to_warn, all arguments will be marked as deprecated.
|
162 | 166 | """
|
163 | 167 |
|
164 | | - def decorator(func): |
| 168 | + def decorator(func: C) ->C: |
165 | 169 | @wraps(func)
|
166 | 170 | def wrapper(*args, **kwargs):
|
167 | 171 | # Get function argument names
|
|
0 commit comments