Format: application/octet-stream
⬇ Download File (7.3 KB)
   1  import builtins
   2  import codecs
   3  import sys
   4  from _typeshed import ReadableBuffer, WriteableBuffer
   5  from types import TracebackType
   6  from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, List, Optional, TextIO, Tuple, Type, TypeVar, Union
   7  
   8  DEFAULT_BUFFER_SIZE: int
   9  
  10  SEEK_SET: int
  11  SEEK_CUR: int
  12  SEEK_END: int
  13  
  14  _T = TypeVar("_T", bound=IOBase)
  15  
  16  open = builtins.open
  17  
  18  if sys.version_info >= (3, 8):
  19      def open_code(path: str) -> IO[bytes]: ...
  20  
  21  BlockingIOError = builtins.BlockingIOError
  22  
  23  class UnsupportedOperation(OSError, ValueError): ...
  24  
  25  class IOBase:
  26      def __iter__(self) -> Iterator[bytes]: ...
  27      def __next__(self) -> bytes: ...
  28      def __enter__(self: _T) -> _T: ...
  29      def __exit__(
  30          self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
  31      ) -> Optional[bool]: ...
  32      def close(self) -> None: ...
  33      def fileno(self) -> int: ...
  34      def flush(self) -> None: ...
  35      def isatty(self) -> bool: ...
  36      def readable(self) -> bool: ...
  37      def readlines(self, __hint: int = ...) -> List[bytes]: ...
  38      def seek(self, __offset: int, __whence: int = ...) -> int: ...
  39      def seekable(self) -> bool: ...
  40      def tell(self) -> int: ...
  41      def truncate(self, __size: Optional[int] = ...) -> int: ...
  42      def writable(self) -> bool: ...
  43      def writelines(self, __lines: Iterable[ReadableBuffer]) -> None: ...
  44      def readline(self, __size: Optional[int] = ...) -> bytes: ...
  45      def __del__(self) -> None: ...
  46      @property
  47      def closed(self) -> bool: ...
  48      def _checkClosed(self, msg: Optional[str] = ...) -> None: ...  # undocumented
  49  
  50  class RawIOBase(IOBase):
  51      def readall(self) -> bytes: ...
  52      def readinto(self, __buffer: WriteableBuffer) -> Optional[int]: ...
  53      def write(self, __b: ReadableBuffer) -> Optional[int]: ...
  54      def read(self, __size: int = ...) -> Optional[bytes]: ...
  55  
  56  class BufferedIOBase(IOBase):
  57      raw: RawIOBase  # This is not part of the BufferedIOBase API and may not exist on some implementations.
  58      def detach(self) -> RawIOBase: ...
  59      def readinto(self, __buffer: WriteableBuffer) -> int: ...
  60      def write(self, __buffer: ReadableBuffer) -> int: ...
  61      def readinto1(self, __buffer: WriteableBuffer) -> int: ...
  62      def read(self, __size: Optional[int] = ...) -> bytes: ...
  63      def read1(self, __size: int = ...) -> bytes: ...
  64  
  65  class FileIO(RawIOBase, BinaryIO):
  66      mode: str
  67      # Technically this is whatever is passed in as file, either a str, a bytes, or an int.
  68      name: Union[int, str]  # type: ignore
  69      def __init__(
  70          self,
  71          file: Union[str, bytes, int],
  72          mode: str = ...,
  73          closefd: bool = ...,
  74          opener: Optional[Callable[[Union[int, str], str], int]] = ...,
  75      ) -> None: ...
  76      @property
  77      def closefd(self) -> bool: ...
  78      def write(self, __b: ReadableBuffer) -> int: ...
  79      def read(self, __size: int = ...) -> bytes: ...
  80      def __enter__(self: _T) -> _T: ...
  81  
  82  class BytesIO(BufferedIOBase, BinaryIO):
  83      def __init__(self, initial_bytes: bytes = ...) -> None: ...
  84      # BytesIO does not contain a "name" field. This workaround is necessary
  85      # to allow BytesIO sub-classes to add this field, as it is defined
  86      # as a read-only property on IO[].
  87      name: Any
  88      def __enter__(self: _T) -> _T: ...
  89      def getvalue(self) -> bytes: ...
  90      def getbuffer(self) -> memoryview: ...
  91      if sys.version_info >= (3, 7):
  92          def read1(self, __size: Optional[int] = ...) -> bytes: ...
  93      else:
  94          def read1(self, __size: Optional[int]) -> bytes: ...  # type: ignore
  95  
  96  class BufferedReader(BufferedIOBase, BinaryIO):
  97      def __enter__(self: _T) -> _T: ...
  98      def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
  99      def peek(self, __size: int = ...) -> bytes: ...
 100      if sys.version_info >= (3, 7):
 101          def read1(self, __size: int = ...) -> bytes: ...
 102      else:
 103          def read1(self, __size: int) -> bytes: ...  # type: ignore
 104  
 105  class BufferedWriter(BufferedIOBase, BinaryIO):
 106      def __enter__(self: _T) -> _T: ...
 107      def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
 108      def write(self, __buffer: ReadableBuffer) -> int: ...
 109  
 110  class BufferedRandom(BufferedReader, BufferedWriter):
 111      def __enter__(self: _T) -> _T: ...
 112      def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
 113      def seek(self, __target: int, __whence: int = ...) -> int: ...
 114      if sys.version_info >= (3, 7):
 115          def read1(self, __size: int = ...) -> bytes: ...
 116      else:
 117          def read1(self, __size: int) -> bytes: ...  # type: ignore
 118  
 119  class BufferedRWPair(BufferedIOBase):
 120      def __init__(self, reader: RawIOBase, writer: RawIOBase, buffer_size: int = ...) -> None: ...
 121      def peek(self, __size: int = ...) -> bytes: ...
 122  
 123  class TextIOBase(IOBase):
 124      encoding: str
 125      errors: Optional[str]
 126      newlines: Union[str, Tuple[str, ...], None]
 127      def __iter__(self) -> Iterator[str]: ...  # type: ignore
 128      def __next__(self) -> str: ...  # type: ignore
 129      def detach(self) -> BinaryIO: ...
 130      def write(self, __s: str) -> int: ...
 131      def writelines(self, __lines: Iterable[str]) -> None: ...  # type: ignore
 132      def readline(self, __size: int = ...) -> str: ...  # type: ignore
 133      def readlines(self, __hint: int = ...) -> List[str]: ...  # type: ignore
 134      def read(self, __size: Optional[int] = ...) -> str: ...
 135      def tell(self) -> int: ...
 136  
 137  class TextIOWrapper(TextIOBase, TextIO):
 138      def __init__(
 139          self,
 140          buffer: IO[bytes],
 141          encoding: Optional[str] = ...,
 142          errors: Optional[str] = ...,
 143          newline: Optional[str] = ...,
 144          line_buffering: bool = ...,
 145          write_through: bool = ...,
 146      ) -> None: ...
 147      @property
 148      def buffer(self) -> BinaryIO: ...
 149      @property
 150      def closed(self) -> bool: ...
 151      @property
 152      def line_buffering(self) -> bool: ...
 153      if sys.version_info >= (3, 7):
 154          @property
 155          def write_through(self) -> bool: ...
 156          def reconfigure(
 157              self,
 158              *,
 159              encoding: Optional[str] = ...,
 160              errors: Optional[str] = ...,
 161              newline: Optional[str] = ...,
 162              line_buffering: Optional[bool] = ...,
 163              write_through: Optional[bool] = ...,
 164          ) -> None: ...
 165      # These are inherited from TextIOBase, but must exist in the stub to satisfy mypy.
 166      def __enter__(self: _T) -> _T: ...
 167      def __iter__(self) -> Iterator[str]: ...  # type: ignore
 168      def __next__(self) -> str: ...  # type: ignore
 169      def writelines(self, __lines: Iterable[str]) -> None: ...  # type: ignore
 170      def readline(self, __size: int = ...) -> str: ...  # type: ignore
 171      def readlines(self, __hint: int = ...) -> List[str]: ...  # type: ignore
 172      def seek(self, __cookie: int, __whence: int = ...) -> int: ...
 173  
 174  class StringIO(TextIOWrapper):
 175      def __init__(self, initial_value: Optional[str] = ..., newline: Optional[str] = ...) -> None: ...
 176      # StringIO does not contain a "name" field. This workaround is necessary
 177      # to allow StringIO sub-classes to add this field, as it is defined
 178      # as a read-only property on IO[].
 179      name: Any
 180      def getvalue(self) -> str: ...
 181  
 182  class IncrementalNewlineDecoder(codecs.IncrementalDecoder):
 183      def __init__(self, decoder: Optional[codecs.IncrementalDecoder], translate: bool, errors: str = ...) -> None: ...
 184      def decode(self, input: Union[bytes, str], final: bool = ...) -> str: ...
 185      @property
 186      def newlines(self) -> Optional[Union[str, Tuple[str, ...]]]: ...
 187