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