massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / coc-python-data / languageServer.0.5.59 / Typeshed / stdlib / 2and3 / codecs.pyi
diff --git a/.config/coc/extensions/coc-python-data/languageServer.0.5.59/Typeshed/stdlib/2and3/codecs.pyi b/.config/coc/extensions/coc-python-data/languageServer.0.5.59/Typeshed/stdlib/2and3/codecs.pyi
new file mode 100644 (file)
index 0000000..3739087
--- /dev/null
@@ -0,0 +1,220 @@
+import sys\r
+from typing import Any, BinaryIO, Callable, Generator, IO, Iterable, List, Optional, Text, TextIO, Tuple, Type, TypeVar, Union\r
+\r
+from abc import abstractmethod\r
+import types\r
+\r
+# TODO: this only satisfies the most common interface, where\r
+# bytes (py2 str) is the raw form and str (py2 unicode) is the cooked form.\r
+# In the long run, both should become template parameters maybe?\r
+# There *are* bytes->bytes and str->str encodings in the standard library.\r
+# They are much more common in Python 2 than in Python 3.\r
+\r
+_Decoded = Text\r
+_Encoded = bytes\r
+\r
+# TODO: It is not possible to specify these signatures correctly, because\r
+# they have an optional positional or keyword argument for errors=.\r
+_Encoder = Callable[[_Decoded], Tuple[_Encoded, int]]  # signature of Codec().encode\r
+_Decoder = Callable[[_Encoded], Tuple[_Decoded, int]]  # signature of Codec().decode\r
+_StreamReader = Callable[[IO[_Encoded]], StreamReader]  # signature of StreamReader __init__\r
+_StreamWriter = Callable[[IO[_Encoded]], StreamWriter]  # signature of StreamWriter __init__\r
+_IncrementalEncoder = Callable[[], IncrementalEncoder]  # signature of IncrementalEncoder __init__\r
+_IncrementalDecoder = Callable[[], IncrementalDecoder]  # signature of IncrementalDecoder __init__\r
+def encode(obj: _Decoded, encoding: str = ..., errors: str = ...) -> _Encoded: ...\r
+def decode(obj: _Encoded, encoding: str = ..., errors: str = ...) -> _Decoded: ...\r
+def lookup(encoding: str) -> CodecInfo: ...\r
+\r
+class CodecInfo(Tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):\r
+    @property\r
+    def encode(self) -> _Encoder: ...\r
+    @property\r
+    def decode(self) -> _Decoder: ...\r
+    @property\r
+    def streamreader(self) -> _StreamReader: ...\r
+    @property\r
+    def streamwriter(self) -> _StreamWriter: ...\r
+    @property\r
+    def incrementalencoder(self) -> _IncrementalEncoder: ...\r
+    @property\r
+    def incrementaldecoder(self) -> _IncrementalDecoder: ...\r
+    name: str\r
+    def __init__(\r
+        self,\r
+        encode: _Encoder,\r
+        decode: _Decoder,\r
+        streamreader: _StreamReader = ...,\r
+        streamwriter: _StreamWriter = ...,\r
+        incrementalencoder: _IncrementalEncoder = ...,\r
+        incrementaldecoder: _IncrementalDecoder = ...,\r
+        name: str = ...,\r
+    ) -> None: ...\r
+\r
+def getencoder(encoding: str) -> _Encoder: ...\r
+def getdecoder(encoding: str) -> _Decoder: ...\r
+def getincrementalencoder(encoding: str) -> _IncrementalEncoder: ...\r
+def getincrementaldecoder(encoding: str) -> _IncrementalDecoder: ...\r
+def getreader(encoding: str) -> _StreamReader: ...\r
+def getwriter(encoding: str) -> _StreamWriter: ...\r
+def register(search_function: Callable[[str], CodecInfo]) -> None: ...\r
+def open(filename: str, mode: str = ..., encoding: str = ..., errors: str = ..., buffering: int = ...) -> StreamReaderWriter: ...\r
+def EncodedFile(file: IO[_Encoded], data_encoding: str, file_encoding: str = ..., errors: str = ...) -> StreamRecoder: ...\r
+def iterencode(iterator: Iterable[_Decoded], encoding: str, errors: str = ...) -> Generator[_Encoded, None, None]: ...\r
+def iterdecode(iterator: Iterable[_Encoded], encoding: str, errors: str = ...) -> Generator[_Decoded, None, None]: ...\r
+\r
+BOM: bytes\r
+BOM_BE: bytes\r
+BOM_LE: bytes\r
+BOM_UTF8: bytes\r
+BOM_UTF16: bytes\r
+BOM_UTF16_BE: bytes\r
+BOM_UTF16_LE: bytes\r
+BOM_UTF32: bytes\r
+BOM_UTF32_BE: bytes\r
+BOM_UTF32_LE: bytes\r
+\r
+# It is expected that different actions be taken depending on which of the\r
+# three subclasses of `UnicodeError` is actually ...ed. However, the Union\r
+# is still needed for at least one of the cases.\r
+def register_error(name: str, error_handler: Callable[[UnicodeError], Tuple[Union[str, bytes], int]]) -> None: ...\r
+def lookup_error(name: str) -> Callable[[UnicodeError], Tuple[Union[str, bytes], int]]: ...\r
+def strict_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...\r
+def replace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...\r
+def ignore_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...\r
+def xmlcharrefreplace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...\r
+def backslashreplace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...\r
+\r
+class Codec:\r
+    # These are sort of @abstractmethod but sort of not.\r
+    # The StreamReader and StreamWriter subclasses only implement one.\r
+    def encode(self, input: _Decoded, errors: str = ...) -> Tuple[_Encoded, int]: ...\r
+    def decode(self, input: _Encoded, errors: str = ...) -> Tuple[_Decoded, int]: ...\r
+\r
+class IncrementalEncoder:\r
+    errors: str\r
+    def __init__(self, errors: str = ...) -> None: ...\r
+    @abstractmethod\r
+    def encode(self, object: _Decoded, final: bool = ...) -> _Encoded: ...\r
+    def reset(self) -> None: ...\r
+    # documentation says int but str is needed for the subclass.\r
+    def getstate(self) -> Union[int, _Decoded]: ...\r
+    def setstate(self, state: Union[int, _Decoded]) -> None: ...\r
+\r
+class IncrementalDecoder:\r
+    errors: str\r
+    def __init__(self, errors: str = ...) -> None: ...\r
+    @abstractmethod\r
+    def decode(self, object: _Encoded, final: bool = ...) -> _Decoded: ...\r
+    def reset(self) -> None: ...\r
+    def getstate(self) -> Tuple[_Encoded, int]: ...\r
+    def setstate(self, state: Tuple[_Encoded, int]) -> None: ...\r
+\r
+# These are not documented but used in encodings/*.py implementations.\r
+class BufferedIncrementalEncoder(IncrementalEncoder):\r
+    buffer: str\r
+    def __init__(self, errors: str = ...) -> None: ...\r
+    @abstractmethod\r
+    def _buffer_encode(self, input: _Decoded, errors: str, final: bool) -> _Encoded: ...\r
+    def encode(self, input: _Decoded, final: bool = ...) -> _Encoded: ...\r
+\r
+class BufferedIncrementalDecoder(IncrementalDecoder):\r
+    buffer: bytes\r
+    def __init__(self, errors: str = ...) -> None: ...\r
+    @abstractmethod\r
+    def _buffer_decode(self, input: _Encoded, errors: str, final: bool) -> Tuple[_Decoded, int]: ...\r
+    def decode(self, object: _Encoded, final: bool = ...) -> _Decoded: ...\r
+\r
+# TODO: it is not possible to specify the requirement that all other\r
+# attributes and methods are passed-through from the stream.\r
+class StreamWriter(Codec):\r
+    errors: str\r
+    def __init__(self, stream: IO[_Encoded], errors: str = ...) -> None: ...\r
+    def write(self, obj: _Decoded) -> None: ...\r
+    def writelines(self, list: Iterable[_Decoded]) -> None: ...\r
+    def reset(self) -> None: ...\r
+\r
+class StreamReader(Codec):\r
+    errors: str\r
+    def __init__(self, stream: IO[_Encoded], errors: str = ...) -> None: ...\r
+    def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> _Decoded: ...\r
+    def readline(self, size: int = ..., keepends: bool = ...) -> _Decoded: ...\r
+    def readlines(self, sizehint: int = ..., keepends: bool = ...) -> List[_Decoded]: ...\r
+    def reset(self) -> None: ...\r
+\r
+_T = TypeVar("_T", bound=StreamReaderWriter)\r
+\r
+# Doesn't actually inherit from TextIO, but wraps a BinaryIO to provide text reading and writing\r
+# and delegates attributes to the underlying binary stream with __getattr__.\r
+class StreamReaderWriter(TextIO):\r
+    def __init__(self, stream: IO[_Encoded], Reader: _StreamReader, Writer: _StreamWriter, errors: str = ...) -> None: ...\r
+    def read(self, size: int = ...) -> _Decoded: ...\r
+    def readline(self, size: Optional[int] = ...) -> _Decoded: ...\r
+    def readlines(self, sizehint: Optional[int] = ...) -> List[_Decoded]: ...\r
+    if sys.version_info >= (3,):\r
+        def __next__(self) -> Text: ...\r
+    else:\r
+        def next(self) -> Text: ...\r
+    def __iter__(self: _T) -> _T: ...\r
+    # This actually returns None, but that's incompatible with the supertype\r
+    def write(self, data: _Decoded) -> int: ...\r
+    def writelines(self, list: Iterable[_Decoded]) -> None: ...\r
+    def reset(self) -> None: ...\r
+    # Same as write()\r
+    def seek(self, offset: int, whence: int = ...) -> int: ...\r
+    def __enter__(self: _T) -> _T: ...\r
+    def __exit__(\r
+        self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType]\r
+    ) -> bool: ...\r
+    def __getattr__(self, name: str) -> Any: ...\r
+    # These methods don't actually exist directly, but they are needed to satisfy the TextIO\r
+    # interface. At runtime, they are delegated through __getattr__.\r
+    def close(self) -> None: ...\r
+    def fileno(self) -> int: ...\r
+    def flush(self) -> None: ...\r
+    def isatty(self) -> bool: ...\r
+    def readable(self) -> bool: ...\r
+    def truncate(self, size: Optional[int] = ...) -> int: ...\r
+    def seekable(self) -> bool: ...\r
+    def tell(self) -> int: ...\r
+    def writable(self) -> bool: ...\r
+\r
+_SRT = TypeVar("_SRT", bound=StreamRecoder)\r
+\r
+class StreamRecoder(BinaryIO):\r
+    def __init__(\r
+        self,\r
+        stream: IO[_Encoded],\r
+        encode: _Encoder,\r
+        decode: _Decoder,\r
+        Reader: _StreamReader,\r
+        Writer: _StreamWriter,\r
+        errors: str = ...,\r
+    ) -> None: ...\r
+    def read(self, size: int = ...) -> bytes: ...\r
+    def readline(self, size: Optional[int] = ...) -> bytes: ...\r
+    def readlines(self, sizehint: Optional[int] = ...) -> List[bytes]: ...\r
+    if sys.version_info >= (3,):\r
+        def __next__(self) -> bytes: ...\r
+    else:\r
+        def next(self) -> bytes: ...\r
+    def __iter__(self: _SRT) -> _SRT: ...\r
+    def write(self, data: bytes) -> int: ...\r
+    def writelines(self, list: Iterable[bytes]) -> int: ...  # type: ignore  # it's supposed to return None\r
+    def reset(self) -> None: ...\r
+    def __getattr__(self, name: str) -> Any: ...\r
+    def __enter__(self: _SRT) -> _SRT: ...\r
+    def __exit__(\r
+        self, type: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType]\r
+    ) -> bool: ...\r
+    # These methods don't actually exist directly, but they are needed to satisfy the BinaryIO\r
+    # interface. At runtime, they are delegated through __getattr__.\r
+    def seek(self, offset: int, whence: int = ...) -> int: ...\r
+    def close(self) -> None: ...\r
+    def fileno(self) -> int: ...\r
+    def flush(self) -> None: ...\r
+    def isatty(self) -> bool: ...\r
+    def readable(self) -> bool: ...\r
+    def truncate(self, size: Optional[int] = ...) -> int: ...\r
+    def seekable(self) -> bool: ...\r
+    def tell(self) -> int: ...\r
+    def writable(self) -> bool: ...\r