deprecation.pyi 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. from collections.abc import Callable
  2. import contextlib
  3. from typing import Any, Literal, ParamSpec, TypedDict, TypeVar, overload
  4. from typing_extensions import (
  5. Unpack, # < Py 3.11
  6. )
  7. _P = ParamSpec("_P")
  8. _R = TypeVar("_R")
  9. _T = TypeVar("_T")
  10. class MatplotlibDeprecationWarning(DeprecationWarning): ...
  11. class DeprecationKwargs(TypedDict, total=False):
  12. message: str
  13. alternative: str
  14. pending: bool
  15. obj_type: str
  16. addendum: str
  17. removal: str | Literal[False]
  18. class NamedDeprecationKwargs(DeprecationKwargs, total=False):
  19. name: str
  20. def warn_deprecated(since: str, **kwargs: Unpack[NamedDeprecationKwargs]) -> None: ...
  21. def deprecated(
  22. since: str, **kwargs: Unpack[NamedDeprecationKwargs]
  23. ) -> Callable[[_T], _T]: ...
  24. class deprecate_privatize_attribute(Any):
  25. def __init__(self, since: str, **kwargs: Unpack[NamedDeprecationKwargs]): ...
  26. def __set_name__(self, owner: type[object], name: str) -> None: ...
  27. DECORATORS: dict[Callable, Callable] = ...
  28. @overload
  29. def rename_parameter(
  30. since: str, old: str, new: str, func: None = ...
  31. ) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ...
  32. @overload
  33. def rename_parameter(
  34. since: str, old: str, new: str, func: Callable[_P, _R]
  35. ) -> Callable[_P, _R]: ...
  36. class _deprecated_parameter_class: ...
  37. _deprecated_parameter: _deprecated_parameter_class
  38. @overload
  39. def delete_parameter(
  40. since: str, name: str, func: None = ..., **kwargs: Unpack[DeprecationKwargs]
  41. ) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ...
  42. @overload
  43. def delete_parameter(
  44. since: str, name: str, func: Callable[_P, _R], **kwargs: Unpack[DeprecationKwargs]
  45. ) -> Callable[_P, _R]: ...
  46. @overload
  47. def make_keyword_only(
  48. since: str, name: str, func: None = ...
  49. ) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ...
  50. @overload
  51. def make_keyword_only(
  52. since: str, name: str, func: Callable[_P, _R]
  53. ) -> Callable[_P, _R]: ...
  54. def deprecate_method_override(
  55. method: Callable[_P, _R],
  56. obj: object | type,
  57. *,
  58. allow_empty: bool = ...,
  59. since: str,
  60. **kwargs: Unpack[NamedDeprecationKwargs]
  61. ) -> Callable[_P, _R]: ...
  62. def suppress_matplotlib_deprecation_warning() -> (
  63. contextlib.AbstractContextManager[None]
  64. ): ...