deprecation.pyi 2.2 KB

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