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:
...

View File

@@ -0,0 +1,6 @@
import codecs
import typing
def search_function(encoding: str) -> codecs.CodecInfo:
...

View File

@@ -0,0 +1,14 @@
import codecs
class IncrementalEncoder(codecs.IncrementalEncoder):
pass
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
pass
class StreamWriter(codecs.StreamWriter):
pass
class StreamReader(codecs.StreamReader):
pass
def getregentry() -> codecs.CodecInfo: pass
def encode(input: str, errors: str = 'strict') -> bytes: pass
def decode(input: bytes, errors: str = 'strict') -> str: pass

View File

@@ -3,14 +3,14 @@
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from abc import ABCMeta, abstractmethod
from typing import Any, Callable, Dict, Sequence
from typing import Any, Callable, Dict, Iterator, Optional, Sequence, Tuple, TypeVar
from collections import namedtuple
_AnyCallable = Callable[..., Any]
_T = TypeVar("T")
_T = TypeVar("_T")
def reduce(function: Callable[[_T], _T],
sequence: Iterator[_T], initial=Optional[_T]) -> _T: ...
sequence: Iterator[_T], initial: Optional[_T] = None) -> _T: ...
WRAPPER_ASSIGNMENTS = ... # type: Sequence[str]
WRAPPER_UPDATES = ... # type: Sequence[str]
@@ -19,11 +19,11 @@ def update_wrapper(wrapper: _AnyCallable, wrapped: _AnyCallable, assigned: Seque
updated: Sequence[str] = ...) -> None: ...
def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_AnyCallable], _AnyCallable]: ...
def total_ordering(cls: type) -> type: ...
def cmp_to_key(mycmp): ...
def cmp_to_key(mycmp: Callable[[_T, _T], bool]) -> Callable[[_T], Any]: ...
class partial(object):
func = ... # Callable[..., Any]
args = ... # type: Tuple[Any]
args = ... # type: Tuple[Any, ...]
keywords = ... # type: Dict[str, Any]
def __init__(self, func: Callable[..., Any], *args, **kwargs) -> None: ...
def __call__(self, *args, **kwargs) -> Any: ...
def __init__(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...

3
stdlib/2.7/httplib.pyi Normal file
View File

@@ -0,0 +1,3 @@
# Stubs for httplib (incomplete)
class HTTPException(Exception): ...

View File

@@ -51,7 +51,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
def doRollover(self): ...
class WatchedFileHandler(logging.FileHandler):
def __init__(self, filename: str, mode: str = ..., encoding: str = None, delay: int = ...): ...
def __init__(self, filename: str, mode: str = ..., encoding: str = None, delay: int = ...) -> None: ...
stream = ... # type: Any
def emit(self, record): ...

View File

@@ -17,8 +17,8 @@ _T = TypeVar('_T')
class Random(_random.Random):
def __init__(self, x: object = None) -> None: ...
def seed(self, x: object = None) -> None: ...
def getstate(self) -> tuple: ...
def setstate(self, state: tuple) -> None: ...
def getstate(self) -> _random._State: ...
def setstate(self, state: _random._State) -> None: ...
def jumpahead(self, n : int) -> None: ...
def getrandbits(self, k: int) -> int: ...
@overload

5
stdlib/2.7/ssl.pyi Normal file
View File

@@ -0,0 +1,5 @@
# Stubs for ssl (incomplete)
import socket
class SSLError(socket.error): ...

62
stdlib/2.7/token.pyi Normal file
View File

@@ -0,0 +1,62 @@
from typing import Dict
ENDMARKER = 0
NAME = 0
NUMBER = 0
STRING = 0
NEWLINE = 0
INDENT = 0
DEDENT = 0
LPAR = 0
RPAR = 0
LSQB = 0
RSQB = 0
COLON = 0
COMMA = 0
SEMI = 0
PLUS = 0
MINUS = 0
STAR = 0
SLASH = 0
VBAR = 0
AMPER = 0
LESS = 0
GREATER = 0
EQUAL = 0
DOT = 0
PERCENT = 0
BACKQUOTE = 0
LBRACE = 0
RBRACE = 0
EQEQUAL = 0
NOTEQUAL = 0
LESSEQUAL = 0
GREATEREQUAL = 0
TILDE = 0
CIRCUMFLEX = 0
LEFTSHIFT = 0
RIGHTSHIFT = 0
DOUBLESTAR = 0
PLUSEQUAL = 0
MINEQUAL = 0
STAREQUAL = 0
SLASHEQUAL = 0
PERCENTEQUAL = 0
AMPEREQUAL = 0
VBAREQUAL = 0
CIRCUMFLEXEQUAL = 0
LEFTSHIFTEQUAL = 0
RIGHTSHIFTEQUAL = 0
DOUBLESTAREQUAL = 0
DOUBLESLASH = 0
DOUBLESLASHEQUAL = 0
AT = 0
OP = 0
ERRORTOKEN = 0
N_TOKENS = 0
NT_OFFSET = 0
tok_name = {} # type: Dict[int, str]
def ISTERMINAL(x) -> bool: ...
def ISNONTERMINAL(x) -> bool: ...
def ISEOF(x) -> bool: ...

View File

@@ -1,11 +1,11 @@
# Stubs for types
from typing import Any
from typing import Any, Tuple, Optional
class ModuleType:
__name__ = ... # type: str
__file__ = ... # type: str
def __init__(self, name: str, doc: Any) -> None: ...
def __init__(self, name: str, doc: str) -> None: ...
class TracebackType:
...
@@ -21,16 +21,16 @@ class ListType:
class CodeType:
co_argcount = ... # type: int
co_cellvars = ... # type: Tuple[str]
co_cellvars = ... # type: Tuple[str, ...]
co_code = ... # type: str
co_consts = ... # type: Tuple[Any]
co_consts = ... # type: Tuple[Any, ...]
co_filename = ... # type: Optional[str]
co_firstlineno = ... # type: int
co_flags = ... # type: int
co_freevars = ... # type: Tuple[str]
co_freevars = ... # type: Tuple[str, ...]
co_lnotab = ... # type: str
co_name = ... # type: str
co_names = ... # type: Tuple[str]
co_names = ... # type: Tuple[str, ...]
co_nlocals= ... # type: int
co_stacksize= ... # type: int
co_varnames = ... # type: Tuple[str]
co_varnames = ... # type: Tuple[str, ...]

View File

@@ -200,7 +200,7 @@ class IO(Iterable[AnyStr], Generic[AnyStr]):
@abstractmethod
def tell(self) -> int: ...
@abstractmethod
def truncate(self, size: int = ...) -> int: ...
def truncate(self, size: int = ...) -> Optional[int]: ...
@abstractmethod
def writable(self) -> bool: ...
# TODO buffer objects

3
stdlib/2.7/unittest.pyi Normal file
View File

@@ -0,0 +1,3 @@
# Stubs for unittest (2.7, incomplete)
class TestCase: ...