io.pyi 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. from io import StringIO as TextIO
  2. from io import BytesIO as BytesIO
  3. from typing import Any, AnyStr, Callable, Generic, IO, List, Optional, Text, Tuple, TypeVar, Union, overload
  4. from typing_extensions import Final
  5. import sys
  6. _T = TypeVar("_T")
  7. class FDCapture(Generic[AnyStr]):
  8. def __init__(self, targetfd: int, tmpfile: Optional[IO[AnyStr]] = ..., now: bool = ..., patchsys: bool = ...) -> None: ...
  9. def start(self) -> None: ...
  10. def done(self) -> IO[AnyStr]: ...
  11. def writeorg(self, data: AnyStr) -> None: ...
  12. class StdCaptureFD:
  13. def __init__(
  14. self,
  15. out: Union[bool, IO[str]] = ...,
  16. err: Union[bool, IO[str]] = ...,
  17. mixed: bool = ...,
  18. in_: bool = ...,
  19. patchsys: bool = ...,
  20. now: bool = ...,
  21. ) -> None: ...
  22. @classmethod
  23. def call(cls, func: Callable[..., _T], *args: Any, **kwargs: Any) -> Tuple[_T, str, str]: ...
  24. def reset(self) -> Tuple[str, str]: ...
  25. def suspend(self) -> Tuple[str, str]: ...
  26. def startall(self) -> None: ...
  27. def resume(self) -> None: ...
  28. def done(self, save: bool = ...) -> Tuple[IO[str], IO[str]]: ...
  29. def readouterr(self) -> Tuple[str, str]: ...
  30. class StdCapture:
  31. def __init__(
  32. self,
  33. out: Union[bool, IO[str]] = ...,
  34. err: Union[bool, IO[str]] = ...,
  35. in_: bool = ...,
  36. mixed: bool = ...,
  37. now: bool = ...,
  38. ) -> None: ...
  39. @classmethod
  40. def call(cls, func: Callable[..., _T], *args: Any, **kwargs: Any) -> Tuple[_T, str, str]: ...
  41. def reset(self) -> Tuple[str, str]: ...
  42. def suspend(self) -> Tuple[str, str]: ...
  43. def startall(self) -> None: ...
  44. def resume(self) -> None: ...
  45. def done(self, save: bool = ...) -> Tuple[IO[str], IO[str]]: ...
  46. def readouterr(self) -> Tuple[IO[str], IO[str]]: ...
  47. # XXX: The type here is not exactly right. If f is IO[bytes] and
  48. # encoding is not None, returns some weird hybrid, not exactly IO[bytes].
  49. def dupfile(
  50. f: IO[AnyStr],
  51. mode: Optional[str] = ...,
  52. buffering: int = ...,
  53. raising: bool = ...,
  54. encoding: Optional[str] = ...,
  55. ) -> IO[AnyStr]: ...
  56. def get_terminal_width() -> int: ...
  57. def ansi_print(
  58. text: Union[str, Text],
  59. esc: Union[Union[str, Text], Tuple[Union[str, Text], ...]],
  60. file: Optional[IO[Any]] = ...,
  61. newline: bool = ...,
  62. flush: bool = ...,
  63. ) -> None: ...
  64. def saferepr(obj, maxsize: int = ...) -> str: ...
  65. class TerminalWriter:
  66. stringio: TextIO
  67. encoding: Final[str]
  68. hasmarkup: bool
  69. def __init__(self, file: Optional[IO[str]] = ..., stringio: bool = ..., encoding: Optional[str] = ...) -> None: ...
  70. @property
  71. def fullwidth(self) -> int: ...
  72. @fullwidth.setter
  73. def fullwidth(self, value: int) -> None: ...
  74. @property
  75. def chars_on_current_line(self) -> int: ...
  76. @property
  77. def width_of_current_line(self) -> int: ...
  78. def markup(
  79. self,
  80. text: str,
  81. *,
  82. black: int = ..., red: int = ..., green: int = ..., yellow: int = ..., blue: int = ..., purple: int = ...,
  83. cyan: int = ..., white: int = ..., Black: int = ..., Red: int = ..., Green: int = ..., Yellow: int = ...,
  84. Blue: int = ..., Purple: int = ..., Cyan: int = ..., White: int = ..., bold: int = ..., light: int = ...,
  85. blink: int = ..., invert: int = ...,
  86. ) -> str: ...
  87. def sep(
  88. self,
  89. sepchar: str,
  90. title: Optional[str] = ...,
  91. fullwidth: Optional[int] = ...,
  92. *,
  93. black: int = ..., red: int = ..., green: int = ..., yellow: int = ..., blue: int = ..., purple: int = ...,
  94. cyan: int = ..., white: int = ..., Black: int = ..., Red: int = ..., Green: int = ..., Yellow: int = ...,
  95. Blue: int = ..., Purple: int = ..., Cyan: int = ..., White: int = ..., bold: int = ..., light: int = ...,
  96. blink: int = ..., invert: int = ...,
  97. ) -> None: ...
  98. def write(
  99. self,
  100. msg: str,
  101. *,
  102. black: int = ..., red: int = ..., green: int = ..., yellow: int = ..., blue: int = ..., purple: int = ...,
  103. cyan: int = ..., white: int = ..., Black: int = ..., Red: int = ..., Green: int = ..., Yellow: int = ...,
  104. Blue: int = ..., Purple: int = ..., Cyan: int = ..., White: int = ..., bold: int = ..., light: int = ...,
  105. blink: int = ..., invert: int = ...,
  106. ) -> None: ...
  107. def line(
  108. self,
  109. s: str = ...,
  110. *,
  111. black: int = ..., red: int = ..., green: int = ..., yellow: int = ..., blue: int = ..., purple: int = ...,
  112. cyan: int = ..., white: int = ..., Black: int = ..., Red: int = ..., Green: int = ..., Yellow: int = ...,
  113. Blue: int = ..., Purple: int = ..., Cyan: int = ..., White: int = ..., bold: int = ..., light: int = ...,
  114. blink: int = ..., invert: int = ...,
  115. ) -> None: ...
  116. def reline(
  117. self,
  118. line: str,
  119. *,
  120. black: int = ..., red: int = ..., green: int = ..., yellow: int = ..., blue: int = ..., purple: int = ...,
  121. cyan: int = ..., white: int = ..., Black: int = ..., Red: int = ..., Green: int = ..., Yellow: int = ...,
  122. Blue: int = ..., Purple: int = ..., Cyan: int = ..., White: int = ..., bold: int = ..., light: int = ...,
  123. blink: int = ..., invert: int = ...,
  124. ) -> None: ...