Update a bunch of stubs

This commit is contained in:
Ben Longbons
2015-10-16 13:11:27 -07:00
parent e4a7edb949
commit 56fe787c74
34 changed files with 483 additions and 277 deletions

View File

@@ -1,165 +1,194 @@
# Stubs for codecs (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
# Better codecs stubs hand-written by o11c.
# https://docs.python.org/2/library/codecs.html
from typing import (
BinaryIO,
Callable,
Iterable,
Iterator,
List,
Tuple,
Union,
)
from typing import Any
from abc import abstractmethod
BOM_UTF8 = ... # type: Any
BOM_LE = ... # type: Any
BOM_BE = ... # type: Any
BOM_UTF32_LE = ... # type: Any
BOM_UTF32_BE = ... # type: Any
BOM = ... # type: Any
BOM_UTF32 = ... # type: Any
BOM32_LE = ... # type: Any
BOM32_BE = ... # type: Any
BOM64_LE = ... # type: Any
BOM64_BE = ... # type: Any
class CodecInfo(tuple):
name = ... # type: Any
encode = ... # type: Any
decode = ... # type: Any
incrementalencoder = ... # type: Any
incrementaldecoder = ... # type: Any
streamwriter = ... # type: Any
streamreader = ... # type: Any
def __new__(cls, encode, decode, streamreader=None, streamwriter=None, incrementalencoder=None, incrementaldecoder=None, name=None): ...
# TODO: this only satisfies the most common interface, where
# str is the raw form and unicode is the cooked form.
# In the long run, both should become template parameters maybe?
# There *are* str->str and unicode->unicode encodings in the standard library.
# And unlike python 3, they are in fairly widespread use.
_decoded = unicode
_encoded = str
# TODO: It is not possible to specify these signatures correctly, because
# they have an optional positional or keyword argument for errors=.
_encode_type = Callable[[_decoded], _encoded] # signature of Codec().encode
_decode_type = Callable[[_encoded], _decoded] # signature of Codec().decode
_stream_reader_type = Callable[[BinaryIO], 'StreamReader'] # signature of StreamReader __init__
_stream_writer_type = Callable[[BinaryIO], 'StreamWriter'] # signature of StreamWriter __init__
_incremental_encoder_type = Callable[[], 'IncrementalEncoder'] # signature of IncrementalEncoder __init__
_incremental_decode_type = Callable[[], 'IncrementalDecoder'] # signature of IncrementalDecoder __init__
def encode(obj: _decoded, encoding: str = 'utf-8', errors: str = 'strict') -> _encoded:
...
def decode(obj: _encoded, encoding: str = 'utf-8', errors: str = 'strict') -> _decoded:
...
def lookup(encoding: str) -> 'CodecInfo':
...
class CodecInfo(Tuple[_encode_type, _decode_type, _stream_reader_type, _stream_writer_type]):
def __init__(self, encode: _encode_type, decode: _decode_type, streamreader: _stream_reader_type = None, streamwriter: _stream_writer_type = None, incrementalencoder: _incremental_encoder_type = None, incrementaldecoder: _incremental_decode_type = None, name: str = None) -> None:
self.encode = encode
self.decode = decode
self.streamreader = streamreader
self.streamwriter = streamwriter
self.incrementalencoder = incrementalencoder
self.incrementaldecoder = incrementaldecoder
self.name = name
def getencoder(encoding: str) -> _encode_type:
...
def getdecoder(encoding: str) -> _encode_type:
...
def getincrementalencoder(encoding: str) -> _incremental_encoder_type:
...
def getincrementaldecoder(encoding: str) -> _incremental_encoder_type:
...
def getreader(encoding: str) -> _stream_reader_type:
...
def getwriter(encoding: str) -> _stream_writer_type:
...
def register(search_function: Callable[[str], CodecInfo]) -> None:
...
def open(filename: str, mode: str = 'r', encoding: str = None, errors: str = 'strict', buffering: int = 1) -> StreamReaderWriter:
...
def EncodedFile(file: BinaryIO, data_encoding: str, file_encoding: str = None, errors = 'strict') -> 'StreamRecoder':
...
def iterencode(iterator: Iterable[_decoded], encoding: str, errors: str = 'strict') -> Iterator[_encoded]:
...
def iterdecode(iterator: Iterable[_encoded], encoding: str, errors: str = 'strict') -> Iterator[_decoded]:
...
BOM = b''
BOM_BE = b''
BOM_LE = b''
BOM_UTF8 = b''
BOM_UTF16 = b''
BOM_UTF16_BE = b''
BOM_UTF16_LE = b''
BOM_UTF32 = b''
BOM_UTF32_BE = b''
BOM_UTF32_LE = b''
# It is expected that different actions be taken depending on which of the
# three subclasses of `UnicodeError` is actually ...ed. However, the Union
# is still needed for at least one of the cases.
def register_error(name: str, error_handler: Callable[[UnicodeError], Tuple[Union[str, bytes], int]]) -> None:
...
def lookup_error(name: str) -> Callable[[UnicodeError], Tuple[Union[str, bytes], int]]:
...
def strict_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]:
...
def replace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]:
...
def ignore_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]:
...
def xmlcharrefreplace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]:
...
def backslashreplace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]:
...
class Codec:
def encode(self, input, errors=''): ...
def decode(self, input, errors=''): ...
# These are sort of @abstractmethod but sort of not.
# The StreamReader and StreamWriter subclasses only implement one.
def encode(self, input: _decoded, errors: str = 'strict') -> Tuple[_encoded, int]:
...
def decode(self, input: _encoded, errors: str = 'strict') -> Tuple[_decoded, int]:
...
class IncrementalEncoder:
errors = ... # type: Any
buffer = ... # type: Any
def __init__(self, errors=''): ...
def encode(self, input, final=False): ...
def reset(self): ...
def getstate(self): ...
def setstate(self, state): ...
class BufferedIncrementalEncoder(IncrementalEncoder):
buffer = ... # type: Any
def __init__(self, errors=''): ...
def encode(self, input, final=False): ...
def reset(self): ...
def getstate(self): ...
def setstate(self, state): ...
def __init__(self, errors: str = 'strict') -> None:
self.errors = errors
@abstractmethod
def encode(self, object: _decoded, final: bool = False) -> _encoded:
...
def reset(self) -> None:
...
# documentation says int but str is needed for the subclass.
def getstate(self) -> Union[int, _decoded]:
...
def setstate(self, state: Union[int, _decoded]) -> None:
...
class IncrementalDecoder:
errors = ... # type: Any
def __init__(self, errors=''): ...
def decode(self, input, final=False): ...
def reset(self): ...
def getstate(self): ...
def setstate(self, state): ...
def __init__(self, errors: str = 'strict') -> None:
self.errors = errors
@abstractmethod
def decode(self, object: _encoded, final: bool = False) -> _decoded:
...
def reset(self) -> None:
...
def getstate(self) -> Tuple[_encoded, int]:
...
def setstate(self, state: Tuple[_encoded, int]) -> None:
...
# These are not documented but used in encodings/*.py implementations.
class BufferedIncrementalEncoder(IncrementalEncoder):
def __init__(self, errors: str = 'strict') -> None:
IncrementalEncoder.__init__(self, errors)
self.buffer = ''
@abstractmethod
def _buffer_encode(self, input: _decoded, errors: str, final: bool) -> _encoded:
...
def encode(self, input: _decoded, final: bool = False) -> _encoded:
...
class BufferedIncrementalDecoder(IncrementalDecoder):
buffer = ... # type: Any
def __init__(self, errors=''): ...
def decode(self, input, final=False): ...
def reset(self): ...
def getstate(self): ...
def setstate(self, state): ...
def __init__(self, errors: str = 'strict') -> None:
IncrementalDecoder.__init__(self, errors)
self.buffer = b''
@abstractmethod
def _buffer_decode(self, input: _encoded, errors: str, final: bool) -> Tuple[_decoded, int]:
...
def decode(self, object: _encoded, final: bool = False) -> _decoded:
...
# TODO: it is not possible to specify the requirement that all other
# attributes and methods are passed-through from the stream.
class StreamWriter(Codec):
stream = ... # type: Any
errors = ... # type: Any
def __init__(self, stream, errors=''): ...
def write(self, object): ...
def writelines(self, list): ...
def reset(self): ...
def seek(self, offset, whence=0): ...
def __getattr__(self, name, getattr=...): ...
def __enter__(self): ...
def __exit__(self, type, value, tb): ...
def __init__(self, stream: BinaryIO, errors: str = 'strict') -> None:
self.errors = errors
def write(self, obj: _decoded) -> None:
...
def writelines(self, list: List[str]) -> None:
...
def reset(self) -> None:
...
class StreamReader(Codec):
stream = ... # type: Any
errors = ... # type: Any
bytebuffer = ... # type: Any
charbuffer = ... # type: Any
linebuffer = ... # type: Any
def __init__(self, stream, errors=''): ...
def decode(self, input, errors=''): ...
def read(self, size=-1, chars=-1, firstline=False): ...
def readline(self, size=None, keepends=True): ...
def readlines(self, sizehint=None, keepends=True): ...
def reset(self): ...
def seek(self, offset, whence=0): ...
def next(self): ...
def __iter__(self): ...
def __getattr__(self, name, getattr=...): ...
def __enter__(self): ...
def __exit__(self, type, value, tb): ...
def __init__(self, stream: BinaryIO, errors: str = 'strict') -> None:
self.errors = errors
def read(self, size: int = -1, chars: int = -1, firstline: bool = False) -> _decoded:
...
def readline(self, size: int = -1, keepends: bool = True) -> _decoded:
...
def readlines(self, sizehint: int = -1, keepends: bool = True) -> List[_decoded]:
...
def reset(self) -> None:
...
class StreamReaderWriter:
encoding = ... # type: Any
stream = ... # type: Any
reader = ... # type: Any
writer = ... # type: Any
errors = ... # type: Any
def __init__(self, stream, Reader, Writer, errors=''): ...
def read(self, size=-1): ...
def readline(self, size=None): ...
def readlines(self, sizehint=None): ...
def next(self): ...
def __iter__(self): ...
def write(self, data): ...
def writelines(self, list): ...
def reset(self): ...
def seek(self, offset, whence=0): ...
def __getattr__(self, name, getattr=...): ...
def __enter__(self): ...
def __exit__(self, type, value, tb): ...
def __init__(self, stream: BinaryIO, Reader: _stream_reader_type, Writer: _stream_writer_type, errors: str = 'strict') -> None:
...
class StreamRecoder:
data_encoding = ... # type: Any
file_encoding = ... # type: Any
stream = ... # type: Any
encode = ... # type: Any
decode = ... # type: Any
reader = ... # type: Any
writer = ... # type: Any
errors = ... # type: Any
def __init__(self, stream, encode, decode, Reader, Writer, errors=''): ...
def read(self, size=-1): ...
def readline(self, size=None): ...
def readlines(self, sizehint=None): ...
def next(self): ...
def __iter__(self): ...
def write(self, data): ...
def writelines(self, list): ...
def reset(self): ...
def __getattr__(self, name, getattr=...): ...
def __enter__(self): ...
def __exit__(self, type, value, tb): ...
def open(filename, mode='', encoding=None, errors='', buffering=1): ...
def EncodedFile(file, data_encoding, file_encoding=None, errors=''): ...
def getencoder(encoding): ...
def getdecoder(encoding): ...
def getincrementalencoder(encoding): ...
def getincrementaldecoder(encoding): ...
def getreader(encoding): ...
def getwriter(encoding): ...
def iterencode(iterator, encoding, errors='', **kwargs): ...
def iterdecode(iterator, encoding, errors='', **kwargs): ...
strict_errors = ... # type: Any
ignore_errors = ... # type: Any
replace_errors = ... # type: Any
xmlcharrefreplace_errors = ... # type: Any
backslashreplace_errors = ... # type: Any
# Names in __all__ with no definition:
# BOM_UTF16
# BOM_UTF16_BE
# BOM_UTF16_LE
# decode
# encode
# lookup
# lookup_error
# register
# register_error
class StreamRecoder(BinaryIO):
def __init__(self, stream: BinaryIO, encode: _encode_type, decode: _decode_type, Reader: _stream_reader_type, Writer: _stream_writer_type, errors: str = 'strict') -> None:
...