|
29 | 29 | import asyncio
|
30 | 30 | import collections.abc
|
31 | 31 | import datetime
|
32 |
| -import functools |
33 | 32 | import itertools
|
34 | 33 | import json
|
35 | 34 | import re
|
@@ -359,57 +358,6 @@ def warn_deprecated(
|
359 | 358 | warnings.simplefilter("default", DeprecationWarning) # reset filter
|
360 | 359 |
|
361 | 360 |
|
362 |
| -def deprecated( |
363 |
| - instead: str | None = None, |
364 |
| - since: str | None = None, |
365 |
| - removed: str | None = None, |
366 |
| - reference: str | None = None, |
367 |
| - stacklevel: int = 3, |
368 |
| - *, |
369 |
| - use_qualname: bool = True, |
370 |
| -) -> Callable[[Callable[[P], T]], Callable[[P], T]]: |
371 |
| - """A decorator implementation of :func:`warn_deprecated`. This will automatically call :func:`warn_deprecated` when |
372 |
| - the decorated function is called. |
373 |
| -
|
374 |
| - Parameters |
375 |
| - ---------- |
376 |
| - instead: Optional[:class:`str`] |
377 |
| - A recommended alternative to the function. |
378 |
| - since: Optional[:class:`str`] |
379 |
| - The version in which the function was deprecated. This should be in the format ``major.minor(.patch)``, where |
380 |
| - the patch version is optional. |
381 |
| - removed: Optional[:class:`str`] |
382 |
| - The version in which the function is planned to be removed. This should be in the format |
383 |
| - ``major.minor(.patch)``, where the patch version is optional. |
384 |
| - reference: Optional[:class:`str`] |
385 |
| - A reference that explains the deprecation, typically a URL to a page such as a changelog entry or a GitHub |
386 |
| - issue/PR. |
387 |
| - stacklevel: :class:`int` |
388 |
| - The stacklevel kwarg passed to :func:`warnings.warn`. Defaults to 3. |
389 |
| - use_qualname: :class:`bool` |
390 |
| - Whether to use the qualified name of the function in the deprecation warning. If ``False``, the short name of |
391 |
| - the function will be used instead. For example, __qualname__ will display as ``Client.login`` while __name__ |
392 |
| - will display as ``login``. Defaults to ``True``. |
393 |
| - """ |
394 |
| - |
395 |
| - def actual_decorator(func: Callable[[P], T]) -> Callable[[P], T]: |
396 |
| - @functools.wraps(func) |
397 |
| - def decorated(*args: P.args, **kwargs: P.kwargs) -> T: |
398 |
| - warn_deprecated( |
399 |
| - name=func.__qualname__ if use_qualname else func.__name__, |
400 |
| - instead=instead, |
401 |
| - since=since, |
402 |
| - removed=removed, |
403 |
| - reference=reference, |
404 |
| - stacklevel=stacklevel, |
405 |
| - ) |
406 |
| - return func(*args, **kwargs) |
407 |
| - |
408 |
| - return decorated |
409 |
| - |
410 |
| - return actual_decorator |
411 |
| - |
412 |
| - |
413 | 361 | def oauth_url(
|
414 | 362 | client_id: int | str,
|
415 | 363 | *,
|
|
0 commit comments