21
21
else :
22
22
from typing_extensions import ParamSpec
23
23
24
- R = TypeVar ("R " )
25
- P = ParamSpec ("P " )
24
+ _R = TypeVar ("_R " )
25
+ _P = ParamSpec ("_P " )
26
26
27
27
28
28
@wrapt .decorator
@@ -153,7 +153,7 @@ def raise_if_nothing_inferred(func, instance, args, kwargs):
153
153
154
154
def deprecate_default_argument_values (
155
155
astroid_version : str = "3.0" , ** arguments : str
156
- ) -> Callable [[Callable [P , R ]], Callable [P , R ]]:
156
+ ) -> Callable [[Callable [_P , _R ]], Callable [_P , _R ]]:
157
157
"""Decorator which emits a DeprecationWarning if any arguments specified
158
158
are None or not passed at all.
159
159
@@ -167,11 +167,11 @@ def deprecate_default_argument_values(
167
167
# Decorator for DeprecationWarning: https://stackoverflow.com/a/49802489
168
168
# Typing of stacked decorators: https://stackoverflow.com/a/68290080
169
169
170
- def deco (func : Callable [P , R ]) -> Callable [P , R ]:
170
+ def deco (func : Callable [_P , _R ]) -> Callable [_P , _R ]:
171
171
"""Decorator function."""
172
172
173
173
@functools .wraps (func )
174
- def wrapper (* args : P .args , ** kwargs : P .kwargs ) -> R :
174
+ def wrapper (* args : _P .args , ** kwargs : _P .kwargs ) -> _R :
175
175
"""Emit DeprecationWarnings if conditions are met."""
176
176
177
177
keys = list (inspect .signature (func ).parameters .keys ())
@@ -212,7 +212,7 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
212
212
213
213
def deprecate_arguments (
214
214
astroid_version : str = "3.0" , ** arguments : str
215
- ) -> Callable [[Callable [P , R ]], Callable [P , R ]]:
215
+ ) -> Callable [[Callable [_P , _R ]], Callable [_P , _R ]]:
216
216
"""Decorator which emits a DeprecationWarning if any arguments specified
217
217
are passed.
218
218
@@ -223,9 +223,9 @@ def deprecate_arguments(
223
223
the default one are enabled.
224
224
"""
225
225
226
- def deco (func : Callable [P , R ]) -> Callable [P , R ]:
226
+ def deco (func : Callable [_P , _R ]) -> Callable [_P , _R ]:
227
227
@functools .wraps (func )
228
- def wrapper (* args : P .args , ** kwargs : P .kwargs ) -> R :
228
+ def wrapper (* args : _P .args , ** kwargs : _P .kwargs ) -> _R :
229
229
230
230
keys = list (inspect .signature (func ).parameters .keys ())
231
231
for arg , note in arguments .items ():
@@ -252,21 +252,21 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
252
252
253
253
def deprecate_default_argument_values (
254
254
astroid_version : str = "3.0" , ** arguments : str
255
- ) -> Callable [[Callable [P , R ]], Callable [P , R ]]:
255
+ ) -> Callable [[Callable [_P , _R ]], Callable [_P , _R ]]:
256
256
"""Passthrough decorator to improve performance if DeprecationWarnings are disabled."""
257
257
258
- def deco (func : Callable [P , R ]) -> Callable [P , R ]:
258
+ def deco (func : Callable [_P , _R ]) -> Callable [_P , _R ]:
259
259
"""Decorator function."""
260
260
return func
261
261
262
262
return deco
263
263
264
264
def deprecate_arguments (
265
265
astroid_version : str = "3.0" , ** arguments : str
266
- ) -> Callable [[Callable [P , R ]], Callable [P , R ]]:
266
+ ) -> Callable [[Callable [_P , _R ]], Callable [_P , _R ]]:
267
267
"""Passthrough decorator to improve performance if DeprecationWarnings are disabled."""
268
268
269
- def deco (func : Callable [P , R ]) -> Callable [P , R ]:
269
+ def deco (func : Callable [_P , _R ]) -> Callable [_P , _R ]:
270
270
"""Decorator function."""
271
271
return func
272
272
0 commit comments