Move 2.7 to 2 (#635)

Closes #579.
This commit is contained in:
Guido van Rossum
2016-10-26 16:24:49 -07:00
committed by GitHub
parent d60bea14f6
commit cb97bb54c0
338 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
# Stubs for BaseHTTPServer (Python 2.7)
from typing import Any, BinaryIO, Mapping, Optional, Tuple, Union
import SocketServer
import mimetools
class HTTPServer(SocketServer.TCPServer):
server_name = ... # type: str
server_port = ... # type: int
def __init__(self, server_address: Tuple[str, int],
RequestHandlerClass: type) -> None: ...
class BaseHTTPRequestHandler:
client_address = ... # type: Tuple[str, int]
server = ... # type: SocketServer.BaseServer
close_connection = ... # type: bool
command = ... # type: str
path = ... # type: str
request_version = ... # type: str
headers = ... # type: mimetools.Message
rfile = ... # type: BinaryIO
wfile = ... # type: BinaryIO
server_version = ... # type: str
sys_version = ... # type: str
error_message_format = ... # type: str
error_content_type = ... # type: str
protocol_version = ... # type: str
MessageClass = ... # type: type
responses = ... # type: Mapping[int, Tuple[str, str]]
def __init__(self, request: bytes, client_address: Tuple[str, int],
server: SocketServer.BaseServer) -> None: ...
def handle(self) -> None: ...
def handle_one_request(self) -> None: ...
def send_error(self, code: int, message: Optional[str] = ...) -> None: ...
def send_response(self, code: int,
message: Optional[str] = ...) -> None: ...
def send_header(self, keyword: str, value: str) -> None: ...
def end_headers(self) -> None: ...
def flush_headers(self) -> None: ...
def log_request(self, code: Union[int, str] = ...,
size: Union[int, str] = ...) -> None: ...
def log_error(self, format: str, *args: Any) -> None: ...
def log_message(self, format: str, *args: Any) -> None: ...
def version_string(self) -> str: ...
def date_time_string(self, timestamp: Optional[int] = ...) -> str: ...
def log_date_time_string(self) -> str: ...
def address_string(self) -> str: ...

103
stdlib/2/ConfigParser.pyi Normal file
View File

@@ -0,0 +1,103 @@
from typing import Any, Tuple, IO
__all__ = ... # type: list[str]
DEFAULTSECT = ... # type: str
MAX_INTERPOLATION_DEPTH = ... # type: int
class Error(Exception):
message = ... # type: Any
def __init__(self, msg: str = ...) -> None: ...
def _get_message(self) -> None: ...
def _set_message(self, value: str) -> None: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
class NoSectionError(Error):
section = ... # type: str
args = ... # type: Tuple[str]
def __init__(self, section: str) -> None: ...
class DuplicateSectionError(Error):
section = ... # type: str
args = ... # type: Tuple[str]
def __init__(self, section: str) -> None: ...
class NoOptionError(Error):
section = ... # type: str
option = ... # type: str
args = ... # type: Tuple[str,str]
def __init__(self, option: str, section: str) -> None: ...
class InterpolationError(Error):
section = ... # type: str
option = ... # type: str
msg = ... # type: str
args = ... # type: Tuple[str,str,str]
def __init__(self, option: str, section: str, msg: str) -> None: ...
class InterpolationMissingOptionError(InterpolationError):
reference = ... # type: str
args = ... # type: Tuple[str,str,str,str]
def __init__(self, option: str, section: str, rawval: str, reference: str) -> None: ...
class InterpolationSyntaxError(InterpolationError): ...
class InterpolationDepthError(InterpolationError):
def __init__(self, option: str, section: str, rawval: str) -> None: ...
class ParsingError(Error):
filename = ... # type: str
errors = ... # type: list[Tuple[Any,Any]]
args = ... # type: Tuple[str]
def __init__(self, filename: str) -> None: ...
def append(self, lineno: Any, line: Any) -> None: ...
class MissingSectionHeaderError(ParsingError):
lineno = ... # type: Any
line = ... # type: Any
args = ... # type: Tuple[str,Any,Any]
def __init__(self, filename: str, lineno: Any, line: Any) -> None: ...
class RawConfigParser:
_dict = ... # type: Any
_sections = ... # type: dict
_defaults = ... # type: dict
_optcre = ... # type: Any
SECTCRE = ... # type: Any
OPTCRE = ... # type: Any
OPTCRE_NV = ... # type: Any
def __init__(self, defaults: dict[Any,Any] = ..., dict_type: Any = ..., allow_no_value: bool = ...) -> None: ...
def defaults(self) -> dict[Any,Any]: ...
def sections(self) -> list[str]: ...
def add_section(self, section: str) -> None: ...
def has_section(self, section: str) -> bool: ...
def options(self, section: str) -> list[str]: ...
def read(self, filenames: str) -> list[str]: ...
def readfp(self, fp: IO[str], filename: str = ...) -> None: ...
def get(self, section: str, option: str) -> str: ...
def items(self, section: str) -> list[Tuple[Any,Any]]: ...
def _get(self, section: str, conv: type, option: str) -> Any: ...
def getint(self, section: str, option: str) -> int: ...
def getfloat(self, section: str, option: str) -> float: ...
_boolean_states = ... # type: dict[str,bool]
def getboolean(self, section: str, option: str) -> bool: ...
def optionxform(self, optionstr: str) -> str: ...
def has_option(self, section: str, option: str) -> bool: ...
def set(self, section: str, option: str, value: Any = ...) -> None: ...
def write(self, fp: file) -> None: ...
def remove_option(self, section: str, option: Any) -> bool: ...
def remove_section(self, section: str) -> bool: ...
def _read(self, fp: file, fpname: str) -> None: ...
class ConfigParser(RawConfigParser):
_KEYCRE = ... # type: Any
def get(self, section: str, option: str, raw: bool = ..., vars: dict = ...) -> Any: ...
def items(self, section: str, raw: bool = ..., vars: dict = ...) -> list[Tuple[str,Any]]: ...
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
def _interpolation_replace(self, match: Any) -> str: ...
class SafeConfigParser(ConfigParser):
_interpvar_re = ... # type: Any
def _interpolate(self, section: str, option: str, rawval: Any, vars: Any) -> str: ...
def _interpolate_some(self, option: str, accum: list, rest: str, section: str, map: dict, depth: int) -> None: ...

44
stdlib/2/Cookie.pyi Normal file
View File

@@ -0,0 +1,44 @@
# Stubs for Cookie (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from typing import Any
class CookieError(Exception): ...
class Morsel(dict):
key = ... # type: Any
def __init__(self): ...
def __setitem__(self, K, V): ...
def isReservedKey(self, K): ...
value = ... # type: Any
coded_value = ... # type: Any
def set(self, key, val, coded_val, LegalChars=..., idmap=..., translate=...): ...
def output(self, attrs=None, header=...): ...
def js_output(self, attrs=None): ...
def OutputString(self, attrs=None): ...
class BaseCookie(dict):
def value_decode(self, val): ...
def value_encode(self, val): ...
def __init__(self, input=None): ...
def __setitem__(self, key, value): ...
def output(self, attrs=None, header=..., sep=...): ...
def js_output(self, attrs=None): ...
def load(self, rawdata): ...
class SimpleCookie(BaseCookie):
def value_decode(self, val): ...
def value_encode(self, val): ...
class SerialCookie(BaseCookie):
def __init__(self, input=None): ...
def value_decode(self, val): ...
def value_encode(self, val): ...
class SmartCookie(BaseCookie):
def __init__(self, input=None): ...
def value_decode(self, val): ...
def value_encode(self, val): ...
Cookie = ... # type: Any

31
stdlib/2/HTMLParser.pyi Normal file
View File

@@ -0,0 +1,31 @@
from typing import List, Tuple, AnyStr
from markupbase import ParserBase
class HTMLParser(ParserBase):
def __init__(self) -> None: ...
def feed(self, feed: AnyStr) -> None: ...
def close(self) -> None: ...
def reset(self) -> None: ...
def get_starttag_text(self) -> AnyStr: ...
def set_cdata_mode(self, AnyStr) -> None: ...
def clear_cdata_mode(self) -> None: ...
def handle_startendtag(self, tag: AnyStr, attrs: List[Tuple[AnyStr, AnyStr]]): ...
def handle_starttag(self, tag: AnyStr, attrs: List[Tuple[AnyStr, AnyStr]]): ...
def handle_endtag(self, tag: AnyStr): ...
def handle_charref(self, name: AnyStr): ...
def handle_entityref(self, name: AnyStr): ...
def handle_data(self, data: AnyStr): ...
def handle_comment(self, data: AnyStr): ...
def handle_decl(self, decl: AnyStr): ...
def handle_pi(self, data: AnyStr): ...
def unknown_decl(self, data: AnyStr): ...
def unescape(self, s: AnyStr) -> AnyStr: ...
class HTMLParseError(Exception):
msg = ... # type: str
lineno = ... # type: int
offset = ... # type: int

29
stdlib/2/Queue.pyi Normal file
View File

@@ -0,0 +1,29 @@
# Stubs for Queue (Python 2)
from typing import Any, TypeVar, Generic
_T = TypeVar('_T')
class Empty(Exception): ...
class Full(Exception): ...
class Queue(Generic[_T]):
maxsize = ... # type: Any
mutex = ... # type: Any
not_empty = ... # type: Any
not_full = ... # type: Any
all_tasks_done = ... # type: Any
unfinished_tasks = ... # type: Any
def __init__(self, maxsize: int = ...) -> None: ...
def task_done(self) -> None: ...
def join(self) -> None: ...
def qsize(self) -> int: ...
def empty(self) -> bool: ...
def full(self) -> bool: ...
def put(self, item: _T, block: bool = ..., timeout: float = ...) -> None: ...
def put_nowait(self, item: _T) -> None: ...
def get(self, block: bool = ..., timeout: float = ...) -> _T: ...
def get_nowait(self) -> _T: ...
class PriorityQueue(Queue): ...
class LifoQueue(Queue): ...

1
stdlib/2/SocketServer.pyi Symbolic link
View File

@@ -0,0 +1 @@
../3/socketserver.pyi

30
stdlib/2/StringIO.pyi Normal file
View File

@@ -0,0 +1,30 @@
# Stubs for StringIO (Python 2)
from typing import Any, IO, AnyStr, Iterator, Iterable, Generic, List
class StringIO(IO[AnyStr], Generic[AnyStr]):
closed = ... # type: bool
softspace = ... # type: int
len = ... # type: int
name = ... # type: str
def __init__(self, buf: AnyStr = ...) -> None: ...
def __iter__(self) -> Iterator[AnyStr]: ...
def next(self) -> AnyStr: ...
def close(self) -> None: ...
def isatty(self) -> bool: ...
def seek(self, pos: int, mode: int = ...) -> None: ...
def tell(self) -> int: ...
def read(self, n: int = ...) -> AnyStr: ...
def readline(self, length: int = ...) -> AnyStr: ...
def readlines(self, sizehint: int = ...) -> List[AnyStr]: ...
def truncate(self, size: int = ...) -> int: ...
def write(self, s: AnyStr) -> None: ...
def writelines(self, iterable: Iterable[AnyStr]) -> None: ...
def flush(self) -> None: ...
def getvalue(self) -> AnyStr: ...
def __enter__(self) -> Any: ...
def __exit__(self, type: Any, value: Any, traceback: Any) -> Any: ...
def fileno(self) -> int: ...
def readable(self) -> bool: ...
def seekable(self) -> bool: ...
def writable(self) -> bool: ...

38
stdlib/2/UserDict.pyi Normal file
View File

@@ -0,0 +1,38 @@
from typing import (Any, Container, Dict, Generic, Iterable, Iterator, List,
Mapping, Sized, Tuple, TypeVar, overload)
_KT = TypeVar('_KT')
_VT = TypeVar('_VT')
class UserDict(Dict[_KT, _VT], Generic[_KT, _VT]):
data = ... # type: Mapping[_KT, _VT]
def __init__(self, initialdata: Mapping[_KT, _VT] = ...) -> None: ...
# TODO: __iter__ is not available for UserDict
class IterableUserDict(UserDict[_KT, _VT], Generic[_KT, _VT]):
...
class DictMixin(Sized, Iterable[_KT], Container[_KT], Generic[_KT, _VT]):
def has_key(self, key: _KT) -> bool: ...
# From typing.Mapping[_KT, _VT]
# (can't inherit because of keys())
def get(self, k: _KT, default: _VT = ...) -> _VT: ...
def values(self) -> List[_VT]: ...
def items(self) -> List[Tuple[_KT, _VT]]: ...
def iterkeys(self) -> Iterator[_KT]: ...
def itervalues(self) -> Iterator[_VT]: ...
def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ...
def __contains__(self, o: Any) -> bool: ...
# From typing.MutableMapping[_KT, _VT]
def clear(self) -> None: ...
def pop(self, k: _KT, default: _VT = ...) -> _VT: ...
def popitem(self) -> Tuple[_KT, _VT]: ...
def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ...
@overload
def update(self, m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
@overload
def update(self, m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...

3
stdlib/2/UserList.pyi Normal file
View File

@@ -0,0 +1,3 @@
import collections
class UserList(collections.MutableSequence): ...

4
stdlib/2/UserString.pyi Normal file
View File

@@ -0,0 +1,4 @@
import collections
class UserString(collections.Sequence): ...
class MutableString(UserString, collections.MutableSequence): ...

939
stdlib/2/__builtin__.pyi Normal file
View File

@@ -0,0 +1,939 @@
# Stubs for builtins (Python 2.7)
# True and False are deliberately omitted because they are keywords in
# Python 3, and stub files conform to Python 3 syntax.
from typing import (
TypeVar, Iterator, Iterable, overload,
Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set,
AbstractSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsAbs,
SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping,
MutableSet, ItemsView, KeysView, ValuesView, Optional, Container,
)
from abc import abstractmethod, ABCMeta
_T = TypeVar('_T')
_T_co = TypeVar('_T_co', covariant=True)
_KT = TypeVar('_KT')
_VT = TypeVar('_VT')
_S = TypeVar('_S')
_T1 = TypeVar('_T1')
_T2 = TypeVar('_T2')
_T3 = TypeVar('_T3')
_T4 = TypeVar('_T4')
class staticmethod: pass # Special, only valid as a decorator.
class classmethod: pass # Special, only valid as a decorator.
class object:
__doc__ = ... # type: str
__class__ = ... # type: type
def __init__(self) -> None: ...
def __new__(cls) -> Any: ...
def __setattr__(self, name: str, value: Any) -> None: ...
def __eq__(self, o: object) -> bool: ...
def __ne__(self, o: object) -> bool: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __hash__(self) -> int: ...
class type:
__bases__ = ... # type: Tuple[type, ...]
__name__ = ... # type: str
__module__ = ... # type: str
__dict__ = ... # type: Dict[unicode, Any]
@overload
def __init__(self, o: object) -> None: ...
@overload
def __init__(self, name: str, bases: Tuple[type, ...], dict: Dict[str, Any]) -> None: ...
# TODO: __new__ may have to be special and not a static method.
@overload
def __new__(cls, o: object) -> type: ...
@overload
def __new__(cls, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type: ...
def __call__(self, *args: Any, **kwds: Any) -> Any: ...
# Only new-style classes
__mro__ = ... # type: Tuple[type, ...]
# Note: the documentation doesnt specify what the return type is, the standard
# implementation seems to be returning a list.
def mro(self) -> List[type]: ...
def __subclasses__(self) -> List[type]: ...
class int(SupportsInt, SupportsFloat, SupportsAbs[int]):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, x: SupportsInt) -> None: ...
@overload
def __init__(self, x: Union[str, unicode, bytearray], base: int = 10) -> None: ...
def bit_length(self) -> int: ...
def __add__(self, x: int) -> int: ...
def __sub__(self, x: int) -> int: ...
def __mul__(self, x: int) -> int: ...
def __floordiv__(self, x: int) -> int: ...
def __div__(self, x: int) -> int: ...
def __truediv__(self, x: int) -> float: ...
def __mod__(self, x: int) -> int: ...
def __radd__(self, x: int) -> int: ...
def __rsub__(self, x: int) -> int: ...
def __rmul__(self, x: int) -> int: ...
def __rfloordiv__(self, x: int) -> int: ...
def __rdiv__(self, x: int) -> int: ...
def __rtruediv__(self, x: int) -> float: ...
def __rmod__(self, x: int) -> int: ...
def __pow__(self, x: int) -> Any: ... # Return type can be int or float, depending on x.
def __rpow__(self, x: int) -> Any: ...
def __and__(self, n: int) -> int: ...
def __or__(self, n: int) -> int: ...
def __xor__(self, n: int) -> int: ...
def __lshift__(self, n: int) -> int: ...
def __rshift__(self, n: int) -> int: ...
def __rand__(self, n: int) -> int: ...
def __ror__(self, n: int) -> int: ...
def __rxor__(self, n: int) -> int: ...
def __rlshift__(self, n: int) -> int: ...
def __rrshift__(self, n: int) -> int: ...
def __neg__(self) -> int: ...
def __pos__(self) -> int: ...
def __invert__(self) -> int: ...
def __eq__(self, x: object) -> bool: ...
def __ne__(self, x: object) -> bool: ...
def __lt__(self, x: int) -> bool: ...
def __le__(self, x: int) -> bool: ...
def __gt__(self, x: int) -> bool: ...
def __ge__(self, x: int) -> bool: ...
def __str__(self) -> str: ...
def __float__(self) -> float: ...
def __int__(self) -> int: ...
def __abs__(self) -> int: ...
def __hash__(self) -> int: ...
class float(SupportsFloat, SupportsInt, SupportsAbs[float]):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, x: SupportsFloat) -> None: ...
@overload
def __init__(self, x: unicode) -> None: ...
@overload
def __init__(self, x: bytearray) -> None: ...
def as_integer_ratio(self) -> Tuple[int, int]: ...
def hex(self) -> str: ...
def is_integer(self) -> bool: ...
@classmethod
def fromhex(cls, s: str) -> float: ...
def __add__(self, x: float) -> float: ...
def __sub__(self, x: float) -> float: ...
def __mul__(self, x: float) -> float: ...
def __floordiv__(self, x: float) -> float: ...
def __div__(self, x: float) -> float: ...
def __truediv__(self, x: float) -> float: ...
def __mod__(self, x: float) -> float: ...
def __pow__(self, x: float) -> float: ...
def __radd__(self, x: float) -> float: ...
def __rsub__(self, x: float) -> float: ...
def __rmul__(self, x: float) -> float: ...
def __rfloordiv__(self, x: float) -> float: ...
def __rdiv__(self, x: float) -> float: ...
def __rtruediv__(self, x: float) -> float: ...
def __rmod__(self, x: float) -> float: ...
def __rpow__(self, x: float) -> float: ...
def __eq__(self, x: object) -> bool: ...
def __ne__(self, x: object) -> bool: ...
def __lt__(self, x: float) -> bool: ...
def __le__(self, x: float) -> bool: ...
def __gt__(self, x: float) -> bool: ...
def __ge__(self, x: float) -> bool: ...
def __neg__(self) -> float: ...
def __pos__(self) -> float: ...
def __str__(self) -> str: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __abs__(self) -> float: ...
def __hash__(self) -> int: ...
def __format__(self, format_spec: AnyStr) -> str: ...
class complex(SupportsAbs[float]):
@overload
def __init__(self, re: float = 0.0, im: float = 0.0) -> None: ...
@overload
def __init__(self, s: str) -> None: ...
@property
def real(self) -> float: ...
@property
def imag(self) -> float: ...
def conjugate(self) -> complex: ...
def __add__(self, x: complex) -> complex: ...
def __sub__(self, x: complex) -> complex: ...
def __mul__(self, x: complex) -> complex: ...
def __pow__(self, x: complex) -> complex: ...
def __div__(self, x: complex) -> complex: ...
def __truediv__(self, x: complex) -> complex: ...
def __radd__(self, x: complex) -> complex: ...
def __rsub__(self, x: complex) -> complex: ...
def __rmul__(self, x: complex) -> complex: ...
def __rpow__(self, x: complex) -> complex: ...
def __rdiv__(self, x: complex) -> complex: ...
def __rtruediv__(self, x: complex) -> complex: ...
def __eq__(self, x: object) -> bool: ...
def __ne__(self, x: object) -> bool: ...
def __neg__(self) -> complex: ...
def __pos__(self) -> complex: ...
def __str__(self) -> str: ...
def __abs__(self) -> float: ...
def __hash__(self) -> int: ...
class basestring(metaclass=ABCMeta): ...
class unicode(basestring, Sequence[unicode]):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, o: object) -> None: ...
@overload
def __init__(self, o: str, encoding: unicode = ..., errors: unicode = ...) -> None: ...
def capitalize(self) -> unicode: ...
def center(self, width: int, fillchar: unicode = u' ') -> unicode: ...
def count(self, x: unicode) -> int: ...
def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ...
def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ...
def endswith(self, suffix: Union[unicode, Tuple[unicode, ...]], start: int = 0,
end: int = ...) -> bool: ...
def expandtabs(self, tabsize: int = 8) -> unicode: ...
def find(self, sub: unicode, start: int = 0, end: int = 0) -> int: ...
def format(self, *args: Any, **kwargs: Any) -> unicode: ...
def format_map(self, map: Mapping[unicode, Any]) -> unicode: ...
def index(self, sub: unicode, start: int = 0, end: int = 0) -> int: ...
def isalnum(self) -> bool: ...
def isalpha(self) -> bool: ...
def isdecimal(self) -> bool: ...
def isdigit(self) -> bool: ...
def isidentifier(self) -> bool: ...
def islower(self) -> bool: ...
def isnumeric(self) -> bool: ...
def isprintable(self) -> bool: ...
def isspace(self) -> bool: ...
def istitle(self) -> bool: ...
def isupper(self) -> bool: ...
def join(self, iterable: Iterable[unicode]) -> unicode: ...
def ljust(self, width: int, fillchar: unicode = u' ') -> unicode: ...
def lower(self) -> unicode: ...
def lstrip(self, chars: unicode = ...) -> unicode: ...
def partition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ...
def replace(self, old: unicode, new: unicode, count: int = ...) -> unicode: ...
def rfind(self, sub: unicode, start: int = 0, end: int = 0) -> int: ...
def rindex(self, sub: unicode, start: int = 0, end: int = 0) -> int: ...
def rjust(self, width: int, fillchar: unicode = u' ') -> unicode: ...
def rpartition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ...
def rsplit(self, sep: Optional[unicode] = ..., maxsplit: int = ...) -> List[unicode]: ...
def rstrip(self, chars: unicode = ...) -> unicode: ...
def split(self, sep: Optional[unicode] = ..., maxsplit: int = ...) -> List[unicode]: ...
def splitlines(self, keepends: bool = ...) -> List[unicode]: ...
def startswith(self, prefix: Union[unicode, Tuple[unicode, ...]], start: int = 0,
end: int = ...) -> bool: ...
def strip(self, chars: unicode = ...) -> unicode: ...
def swapcase(self) -> unicode: ...
def title(self) -> unicode: ...
def translate(self, table: Union[Dict[int, Any], unicode]) -> unicode: ...
def upper(self) -> unicode: ...
def zfill(self, width: int) -> unicode: ...
@overload
def __getitem__(self, i: int) -> unicode: ...
@overload
def __getitem__(self, s: slice) -> unicode: ...
def __getslice__(self, start: int, stop: int) -> unicode: ...
def __add__(self, s: unicode) -> unicode: ...
def __mul__(self, n: int) -> unicode: ...
def __mod__(self, x: Any) -> unicode: ...
def __eq__(self, x: object) -> bool: ...
def __ne__(self, x: object) -> bool: ...
def __lt__(self, x: unicode) -> bool: ...
def __le__(self, x: unicode) -> bool: ...
def __gt__(self, x: unicode) -> bool: ...
def __ge__(self, x: unicode) -> bool: ...
def __len__(self) -> int: ...
def __contains__(self, s: object) -> bool: ...
def __iter__(self) -> Iterator[unicode]: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __hash__(self) -> int: ...
class str(basestring, Sequence[str]):
def __init__(self, object: object) -> None: ...
def capitalize(self) -> str: ...
def center(self, width: int, fillchar: str = ...) -> str: ...
def count(self, x: unicode) -> int: ...
def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ...
def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ...
def endswith(self, suffix: Union[unicode, Tuple[unicode, ...]]) -> bool: ...
def expandtabs(self, tabsize: int = 8) -> str: ...
def find(self, sub: unicode, start: int = 0, end: int = 0) -> int: ...
def format(self, *args: Any, **kwargs: Any) -> str: ...
def index(self, sub: unicode, start: int = 0, end: int = 0) -> int: ...
def isalnum(self) -> bool: ...
def isalpha(self) -> bool: ...
def isdigit(self) -> bool: ...
def islower(self) -> bool: ...
def isspace(self) -> bool: ...
def istitle(self) -> bool: ...
def isupper(self) -> bool: ...
def join(self, iterable: Iterable[AnyStr]) -> AnyStr: ...
def ljust(self, width: int, fillchar: str = ...) -> str: ...
def lower(self) -> str: ...
@overload
def lstrip(self, chars: str = ...) -> str: ...
@overload
def lstrip(self, chars: unicode) -> unicode: ...
@overload
def partition(self, sep: bytearray) -> Tuple[str, bytearray, str]: ...
@overload
def partition(self, sep: str) -> Tuple[str, str, str]: ...
@overload
def partition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ...
def replace(self, old: AnyStr, new: AnyStr, count: int = ...) -> AnyStr: ...
def rfind(self, sub: unicode, start: int = 0, end: int = 0) -> int: ...
def rindex(self, sub: unicode, start: int = 0, end: int = 0) -> int: ...
def rjust(self, width: int, fillchar: str = ...) -> str: ...
@overload
def rpartition(self, sep: bytearray) -> Tuple[str, bytearray, str]: ...
@overload
def rpartition(self, sep: str) -> Tuple[str, str, str]: ...
@overload
def rpartition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ...
@overload
def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ...
@overload
def rsplit(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ...
@overload
def rstrip(self, chars: str = ...) -> str: ...
@overload
def rstrip(self, chars: unicode) -> unicode: ...
@overload
def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[str]: ...
@overload
def split(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ...
def splitlines(self, keepends: bool = ...) -> List[str]: ...
def startswith(self, prefix: Union[unicode, Tuple[unicode, ...]]) -> bool: ...
@overload
def strip(self, chars: str = ...) -> str: ...
@overload
def strip(self, chars: unicode) -> unicode: ...
def swapcase(self) -> str: ...
def title(self) -> str: ...
def translate(self, table: Optional[AnyStr], deletechars: AnyStr = ...) -> AnyStr: ...
def upper(self) -> str: ...
def zfill(self, width: int) -> str: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[str]: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __hash__(self) -> int: ...
@overload
def __getitem__(self, i: int) -> str: ...
@overload
def __getitem__(self, s: slice) -> str: ...
def __getslice__(self, start: int, stop: int) -> str: ...
def __add__(self, s: AnyStr) -> AnyStr: ...
def __mul__(self, n: int) -> str: ...
def __rmul__(self, n: int) -> str: ...
def __contains__(self, o: object) -> bool: ...
def __eq__(self, x: object) -> bool: ...
def __ne__(self, x: object) -> bool: ...
def __lt__(self, x: unicode) -> bool: ...
def __le__(self, x: unicode) -> bool: ...
def __gt__(self, x: unicode) -> bool: ...
def __ge__(self, x: unicode) -> bool: ...
def __mod__(self, x: Any) -> str: ...
class bytearray(MutableSequence[int]):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, x: Union[Iterable[int], str]) -> None: ...
@overload
def __init__(self, x: unicode, encoding: unicode,
errors: unicode = ...) -> None: ...
@overload
def __init__(self, length: int) -> None: ...
def capitalize(self) -> bytearray: ...
def center(self, width: int, fillchar: str = ...) -> bytearray: ...
def count(self, x: str) -> int: ...
def decode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ...
def endswith(self, suffix: Union[str, Tuple[str, ...]]) -> bool: ...
def expandtabs(self, tabsize: int = 8) -> bytearray: ...
def find(self, sub: str, start: int = 0, end: int = ...) -> int: ...
def index(self, sub: str, start: int = 0, end: int = ...) -> int: ...
def insert(self, index: int, object: int) -> None: ...
def isalnum(self) -> bool: ...
def isalpha(self) -> bool: ...
def isdigit(self) -> bool: ...
def islower(self) -> bool: ...
def isspace(self) -> bool: ...
def istitle(self) -> bool: ...
def isupper(self) -> bool: ...
def join(self, iterable: Iterable[str]) -> bytearray: ...
def ljust(self, width: int, fillchar: str = ...) -> bytearray: ...
def lower(self) -> bytearray: ...
def lstrip(self, chars: str = ...) -> bytearray: ...
def partition(self, sep: str) -> Tuple[bytearray, bytearray, bytearray]: ...
def replace(self, old: str, new: str, count: int = ...) -> bytearray: ...
def rfind(self, sub: str, start: int = 0, end: int = ...) -> int: ...
def rindex(self, sub: str, start: int = 0, end: int = ...) -> int: ...
def rjust(self, width: int, fillchar: str = ...) -> bytearray: ...
def rpartition(self, sep: str) -> Tuple[bytearray, bytearray, bytearray]: ...
def rsplit(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[bytearray]: ...
def rstrip(self, chars: str = ...) -> bytearray: ...
def split(self, sep: Optional[str] = ..., maxsplit: int = ...) -> List[bytearray]: ...
def splitlines(self, keepends: bool = ...) -> List[bytearray]: ...
def startswith(self, prefix: Union[str, Tuple[str, ...]]) -> bool: ...
def strip(self, chars: str = ...) -> bytearray: ...
def swapcase(self) -> bytearray: ...
def title(self) -> bytearray: ...
def translate(self, table: str) -> bytearray: ...
def upper(self) -> bytearray: ...
def zfill(self, width: int) -> bytearray: ...
@staticmethod
def fromhex(x: str) -> bytearray: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[int]: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __hash__(self) -> int: ...
@overload
def __getitem__(self, i: int) -> int: ...
@overload
def __getitem__(self, s: slice) -> bytearray: ...
def __getslice__(self, start: int, stop: int) -> bytearray: ...
@overload
def __setitem__(self, i: int, x: int) -> None: ...
@overload
def __setitem__(self, s: slice, x: Union[Iterable[int], str]) -> None: ...
def __setslice__(self, start: int, stop: int, x: Union[Sequence[int], str]) -> None: ...
def __delitem__(self, i: Union[int, slice]) -> None: ...
def __delslice__(self, start: int, stop: int) -> None: ...
def __add__(self, s: str) -> bytearray: ...
def __mul__(self, n: int) -> bytearray: ...
def __contains__(self, o: object) -> bool: ...
def __eq__(self, x: object) -> bool: ...
def __ne__(self, x: object) -> bool: ...
def __lt__(self, x: str) -> bool: ...
def __le__(self, x: str) -> bool: ...
def __gt__(self, x: str) -> bool: ...
def __ge__(self, x: str) -> bool: ...
class bool(int, SupportsInt, SupportsFloat):
def __init__(self, o: object = ...) -> None: ...
class slice:
start = 0
step = 0
stop = 0
def __init__(self, start: int, stop: int = 0, step: int = 0) -> None: ...
class tuple(Sequence[_T_co], Generic[_T_co]):
def __init__(self, iterable: Iterable[_T_co] = ...) -> None: ...
def __len__(self) -> int: ...
def __contains__(self, x: object) -> bool: ...
@overload
def __getitem__(self, x: int) -> _T_co: ...
@overload
def __getitem__(self, x: slice) -> Tuple[_T_co, ...]: ...
def __iter__(self) -> Iterator[_T_co]: ...
def __lt__(self, x: Tuple[_T_co, ...]) -> bool: ...
def __le__(self, x: Tuple[_T_co, ...]) -> bool: ...
def __gt__(self, x: Tuple[_T_co, ...]) -> bool: ...
def __ge__(self, x: Tuple[_T_co, ...]) -> bool: ...
def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ...
def __mul__(self, n: int) -> Tuple[_T_co, ...]: ...
def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ...
def count(self, x: Any) -> int: ...
def index(self, x: Any) -> int: ...
class function:
# TODO name of the class (corresponds to Python 'function' class)
__name__ = ... # type: str
__module__ = ... # type: str
class list(MutableSequence[_T], Generic[_T]):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, iterable: Iterable[_T]) -> None: ...
def append(self, object: _T) -> None: ...
def extend(self, iterable: Iterable[_T]) -> None: ...
def pop(self, index: int = -1) -> _T: ...
def index(self, object: _T, start: int = 0, stop: int = ...) -> int: ...
def count(self, object: _T) -> int: ...
def insert(self, index: int, object: _T) -> None: ...
def remove(self, object: _T) -> None: ...
def reverse(self) -> None: ...
def sort(self, cmp: Callable[[_T, _T], Any] = ..., key: Callable[[_T], Any] = ..., reverse: bool = ...) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
def __str__(self) -> str: ...
def __hash__(self) -> int: ...
@overload
def __getitem__(self, i: int) -> _T: ...
@overload
def __getitem__(self, s: slice) -> List[_T]: ...
def __getslice__(self, start: int, stop: int) -> List[_T]: ...
@overload
def __setitem__(self, i: int, o: _T) -> None: ...
@overload
def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ...
def __setslice__(self, start: int, stop: int, o: Sequence[_T]) -> None: ...
def __delitem__(self, i: Union[int, slice]) -> None: ...
def __delslice(self, start: int, stop: int) -> None: ...
def __add__(self, x: List[_T]) -> List[_T]: ...
def __iadd__(self, x: Iterable[_T]) -> List[_T]: ...
def __mul__(self, n: int) -> List[_T]: ...
def __rmul__(self, n: int) -> List[_T]: ...
def __contains__(self, o: object) -> bool: ...
def __reversed__(self) -> Iterator[_T]: ...
def __gt__(self, x: List[_T]) -> bool: ...
def __ge__(self, x: List[_T]) -> bool: ...
def __lt__(self, x: List[_T]) -> bool: ...
def __le__(self, x: List[_T]) -> bool: ...
class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
# NOTE: Keyword arguments are special. If they are used, _KT must include
# str, but we have no way of enforcing it here.
@overload
def __init__(self, **kwargs: _VT) -> None: ...
@overload
def __init__(self, map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
@overload
def __init__(self, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
def has_key(self, k: _KT) -> bool: ...
def clear(self) -> None: ...
def copy(self) -> Dict[_KT, _VT]: ...
def get(self, k: _KT, default: _VT = None) -> _VT: ...
def pop(self, k: _KT, default: _VT = ...) -> _VT: ...
def popitem(self) -> Tuple[_KT, _VT]: ...
def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ...
@overload
def update(self, m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ...
@overload
def update(self, m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
def keys(self) -> List[_KT]: ...
def values(self) -> List[_VT]: ...
def items(self) -> List[Tuple[_KT, _VT]]: ...
def iterkeys(self) -> Iterator[_KT]: ...
def itervalues(self) -> Iterator[_VT]: ...
def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ...
def viewkeys(self) -> KeysView[_KT]: ...
def viewvalues(self) -> ValuesView[_VT]: ...
def viewitems(self) -> ItemsView[_KT, _VT]: ...
@staticmethod
@overload
def fromkeys(seq: Sequence[_T]) -> Dict[_T, Any]: ... # TODO: Actually a class method (mypy/issues#328)
@staticmethod
@overload
def fromkeys(seq: Sequence[_T], value: _S) -> Dict[_T, _S]: ...
def __len__(self) -> int: ...
def __getitem__(self, k: _KT) -> _VT: ...
def __setitem__(self, k: _KT, v: _VT) -> None: ...
def __delitem__(self, v: _KT) -> None: ...
def __contains__(self, o: object) -> bool: ...
def __iter__(self) -> Iterator[_KT]: ...
def __str__(self) -> str: ...
class set(MutableSet[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...) -> None: ...
def add(self, element: _T) -> None: ...
def clear(self) -> None: ...
def copy(self) -> set[_T]: ...
def difference(self, *s: Iterable[Any]) -> set[_T]: ...
def difference_update(self, *s: Iterable[Any]) -> None: ...
def discard(self, element: _T) -> None: ...
def intersection(self, *s: Iterable[Any]) -> set[_T]: ...
def intersection_update(self, *s: Iterable[Any]) -> None: ...
def isdisjoint(self, s: Iterable[Any]) -> bool: ...
def issubset(self, s: Iterable[Any]) -> bool: ...
def issuperset(self, s: Iterable[Any]) -> bool: ...
def pop(self) -> _T: ...
def remove(self, element: _T) -> None: ...
def symmetric_difference(self, s: Iterable[_T]) -> set[_T]: ...
def symmetric_difference_update(self, s: Iterable[_T]) -> None: ...
def union(self, *s: Iterable[_T]) -> set[_T]: ...
def update(self, *s: Iterable[_T]) -> None: ...
def __len__(self) -> int: ...
def __contains__(self, o: object) -> bool: ...
def __iter__(self) -> Iterator[_T]: ...
def __str__(self) -> str: ...
def __and__(self, s: AbstractSet[Any]) -> set[_T]: ...
def __iand__(self, s: AbstractSet[Any]) -> set[_T]: ...
def __or__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ...
def __ior__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ...
def __sub__(self, s: AbstractSet[Any]) -> set[_T]: ...
def __isub__(self, s: AbstractSet[Any]) -> set[_T]: ...
def __xor__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ...
def __ixor__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ...
def __le__(self, s: AbstractSet[Any]) -> bool: ...
def __lt__(self, s: AbstractSet[Any]) -> bool: ...
def __ge__(self, s: AbstractSet[Any]) -> bool: ...
def __gt__(self, s: AbstractSet[Any]) -> bool: ...
# TODO more set operations
class frozenset(AbstractSet[_T], Generic[_T]):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, iterable: Iterable[_T]) -> None: ...
def copy(self) -> frozenset[_T]: ...
def difference(self, *s: Iterable[Any]) -> frozenset[_T]: ...
def intersection(self, *s: Iterable[Any]) -> frozenset[_T]: ...
def isdisjoint(self, s: Iterable[_T]) -> bool: ...
def issubset(self, s: Iterable[Any]) -> bool: ...
def issuperset(self, s: Iterable[Any]) -> bool: ...
def symmetric_difference(self, s: Iterable[_T]) -> frozenset[_T]: ...
def union(self, *s: Iterable[_T]) -> frozenset[_T]: ...
def __len__(self) -> int: ...
def __contains__(self, o: object) -> bool: ...
def __iter__(self) -> Iterator[_T]: ...
def __str__(self) -> str: ...
def __and__(self, s: AbstractSet[_T]) -> frozenset[_T]: ...
def __or__(self, s: AbstractSet[_S]) -> frozenset[Union[_T, _S]]: ...
def __sub__(self, s: AbstractSet[_T]) -> frozenset[_T]: ...
def __xor__(self, s: AbstractSet[_S]) -> frozenset[Union[_T, _S]]: ...
def __le__(self, s: AbstractSet[Any]) -> bool: ...
def __lt__(self, s: AbstractSet[Any]) -> bool: ...
def __ge__(self, s: AbstractSet[Any]) -> bool: ...
def __gt__(self, s: AbstractSet[Any]) -> bool: ...
class enumerate(Iterator[Tuple[int, _T]], Generic[_T]):
def __init__(self, iterable: Iterable[_T], start: int = 0) -> None: ...
def __iter__(self) -> Iterator[Tuple[int, _T]]: ...
def next(self) -> Tuple[int, _T]: ...
# TODO __getattribute__
class xrange(Sized, Iterable[int], Reversible[int]):
@overload
def __init__(self, stop: int) -> None: ...
@overload
def __init__(self, start: int, stop: int, step: int = 1) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[int]: ...
def __getitem__(self, i: int) -> int: ...
def __reversed__(self) -> Iterator[int]: ...
class module:
__name__ = ... # type: str
__file__ = ... # type: str
__dict__ = ... # type: Dict[unicode, Any]
class property:
def __init__(self, fget: Callable[[Any], Any] = None,
fset: Callable[[Any, Any], None] = None,
fdel: Callable[[Any], None] = None, doc: str = None) -> None: ...
def getter(self, fget: Callable[[Any], Any]) -> property: ...
def setter(self, fset: Callable[[Any, Any], None]) -> property: ...
def deleter(self, fdel: Callable[[Any], None]) -> property: ...
def __get__(self, obj: Any, type: type=None) -> Any: ...
def __set__(self, obj: Any, value: Any) -> None: ...
def __delete__(self, obj: Any) -> None: ...
long = int
bytes = str
NotImplemented = ... # type: Any
def abs(n: SupportsAbs[_T]) -> _T: ...
def all(i: Iterable) -> bool: ...
def any(i: Iterable) -> bool: ...
def bin(number: int) -> str: ...
def callable(o: object) -> bool: ...
def chr(code: int) -> str: ...
def compile(source: Any, filename: unicode, mode: str, flags: int = 0,
dont_inherit: int = 0) -> Any: ...
def delattr(o: Any, name: unicode) -> None: ...
def dir(o: object = ...) -> List[str]: ...
@overload
def divmod(a: int, b: int) -> Tuple[int, int]: ...
@overload
def divmod(a: float, b: float) -> Tuple[float, float]: ...
def exit(code: int = ...) -> None: ...
def filter(function: Callable[[_T], Any],
iterable: Iterable[_T]) -> List[_T]: ...
def format(o: object, format_spec: str = '') -> str: ... # TODO unicode
def getattr(o: Any, name: unicode, default: Any = None) -> Any: ...
def hasattr(o: Any, name: unicode) -> bool: ...
def hash(o: object) -> int: ...
def hex(i: int) -> str: ... # TODO __index__
def id(o: object) -> int: ...
def input(prompt: unicode = ...) -> Any: ...
def intern(string: str) -> str: ...
@overload
def iter(iterable: Iterable[_T]) -> Iterator[_T]: ...
@overload
def iter(function: Callable[[], _T], sentinel: _T) -> Iterator[_T]: ...
def isinstance(o: object, t: Union[type, Tuple[type, ...]]) -> bool: ...
def issubclass(cls: type, classinfo: Union[type, Tuple[type, ...]]) -> bool: ...
def len(o: Sized) -> int: ...
@overload
def map(func: Callable[[_T1], _S], iter1: Iterable[_T1]) -> List[_S]: ...
@overload
def map(func: Callable[[_T1, _T2], _S],
iter1: Iterable[_T1],
iter2: Iterable[_T2]) -> List[_S]: ... # TODO more than two iterables
@overload
def max(arg1: _T, arg2: _T, *args: _T, key: Callable[[_T], Any] = ...) -> _T: ...
@overload
def max(iterable: Iterable[_T], key: Callable[[_T], Any] = ...) -> _T: ...
@overload
def min(arg1: _T, arg2: _T, *args: _T, key: Callable[[_T], Any] = ...) -> _T: ...
@overload
def min(iterable: Iterable[_T], key: Callable[[_T], Any] = ...) -> _T: ...
@overload
def next(i: Iterator[_T]) -> _T: ...
@overload
def next(i: Iterator[_T], default: _T) -> _T: ...
def oct(i: int) -> str: ... # TODO __index__
@overload
def open(file: str, mode: str = 'r', buffering: int = ...) -> BinaryIO: ...
@overload
def open(file: unicode, mode: str = 'r', buffering: int = ...) -> BinaryIO: ...
@overload
def open(file: int, mode: str = 'r', buffering: int = ...) -> BinaryIO: ...
def ord(c: unicode) -> int: ...
# This is only available after from __future__ import print_function.
def print(*values: Any, sep: unicode = u' ', end: unicode = u'\n',
file: IO[Any] = ...) -> None: ...
@overload
def pow(x: int, y: int) -> Any: ... # The return type can be int or float, depending on y.
@overload
def pow(x: int, y: int, z: int) -> Any: ...
@overload
def pow(x: float, y: float) -> float: ...
@overload
def pow(x: float, y: float, z: float) -> float: ...
def quit(code: int = ...) -> None: ...
def range(x: int, y: int = 0, step: int = 1) -> List[int]: ...
def raw_input(prompt: unicode = ...) -> str: ...
@overload
def reduce(function: Callable[[_T, _S], _T], iterable: Iterable[_S], initializer: _T) -> _T: ...
@overload
def reduce(function: Callable[[_T, _T], _T], iterable: Iterable[_T]) -> _T: ...
def reload(module: Any) -> Any: ...
@overload
def reversed(object: Reversible[_T]) -> Iterator[_T]: ...
@overload
def reversed(object: Sequence[_T]) -> Iterator[_T]: ...
def repr(o: object) -> str: ...
@overload
def round(number: float) -> float: ...
@overload
def round(number: float, ndigits: int) -> float: ... # Always return a float if given ndigits.
@overload
def round(number: SupportsRound[_T]) -> _T: ...
@overload
def round(number: SupportsRound[_T], ndigits: int) -> _T: ...
def setattr(object: Any, name: unicode, value: Any) -> None: ...
def sorted(iterable: Iterable[_T], *,
cmp: Callable[[_T, _T], int] = ...,
key: Callable[[_T], Any] = ...,
reverse: bool = ...) -> List[_T]: ...
def sum(iterable: Iterable[_T], start: _T = ...) -> _T: ...
def unichr(i: int) -> unicode: ...
def vars(object: Any = ...) -> Dict[str, Any]: ...
@overload
def zip(iter1: Iterable[_T1]) -> List[Tuple[_T1]]: ...
@overload
def zip(iter1: Iterable[_T1],
iter2: Iterable[_T2]) -> List[Tuple[_T1, _T2]]: ...
@overload
def zip(iter1: Iterable[_T1], iter2: Iterable[_T2],
iter3: Iterable[_T3]) -> List[Tuple[_T1, _T2, _T3]]: ...
@overload
def zip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
iter4: Iterable[_T4]) -> List[Tuple[_T1, _T2,
_T3, _T4]]: ... # TODO more than four iterables
def __import__(name: unicode,
globals: Dict[str, Any] = ...,
locals: Dict[str, Any] = ...,
fromlist: List[str] = ..., level: int = ...) -> Any: ...
def globals() -> Dict[str, Any]: ...
def locals() -> Dict[str, Any]: ...
# Actually the type of Ellipsis is <type 'ellipsis'>, but since it's
# not exposed anywhere under that name, we make it private here.
class ellipsis: ...
Ellipsis = ... # type: ellipsis
# TODO: buffer support is incomplete; e.g. some_string.startswith(some_buffer) doesn't type check.
AnyBuffer = TypeVar('AnyBuffer', str, unicode, bytearray, buffer)
class buffer(Sized):
def __init__(self, object: AnyBuffer, offset: int = ..., size: int = ...) -> None: ...
def __add__(self, other: AnyBuffer) -> str: ...
def __cmp__(self, other: AnyBuffer) -> bool: ...
def __getitem__(self, key: Union[int, slice]) -> str: ...
def __getslice__(self, i: int, j: int) -> str: ...
def __len__(self) -> int: ...
def __mul__(self, x: int) -> str: ...
class memoryview(Sized, Container[bytes]):
format = ... # type: str
itemsize = ... # type: int
shape = ... # type: Optional[Tuple[int, ...]]
strides = ... # type: Optional[Tuple[int, ...]]
suboffsets = ... # type: Optional[Tuple[int, ...]]
readonly = ... # type: bool
ndim = ... # type: int
def __init__(self, obj: Union[str, bytearray, buffer, memoryview]) -> None: ...
@overload
def __getitem__(self, i: int) -> bytes: ...
@overload
def __getitem__(self, s: slice) -> memoryview: ...
def __contains__(self, x: object) -> bool: ...
def __iter__(self) -> Iterator[bytes]: ...
def __len__(self) -> int: ...
@overload
def __setitem__(self, i: int, o: bytes) -> None: ...
@overload
def __setitem__(self, s: slice, o: Sequence[bytes]) -> None: ...
@overload
def __setitem__(self, s: slice, o: memoryview) -> None: ...
def tobytes(self) -> bytes: ...
def tolist(self) -> List[int]: ...
class BaseException:
args = ... # type: Any
message = ... # type: str
def __init__(self, *args: Any) -> None: ...
def with_traceback(self, tb: Any) -> BaseException: ...
class GeneratorExit(BaseException): ...
class KeyboardInterrupt(BaseException): ...
class SystemExit(BaseException):
code = 0
class Exception(BaseException): ...
class StopIteration(Exception): ...
class StandardError(Exception): ...
class ArithmeticError(StandardError): ...
class BufferError(StandardError): ...
class EnvironmentError(StandardError):
errno = 0
strerror = ... # type: str
# TODO can this be unicode?
filename = ... # type: str
class LookupError(StandardError): ...
class RuntimeError(StandardError): ...
class ValueError(StandardError): ...
class AssertionError(StandardError): ...
class AttributeError(StandardError): ...
class EOFError(StandardError): ...
class FloatingPointError(ArithmeticError): ...
class IOError(EnvironmentError): ...
class ImportError(StandardError): ...
class IndexError(LookupError): ...
class KeyError(LookupError): ...
class MemoryError(StandardError): ...
class NameError(StandardError): ...
class NotImplementedError(RuntimeError): ...
class OSError(EnvironmentError): ...
class WindowsError(OSError):
winerror = ... # type: int
class OverflowError(ArithmeticError): ...
class ReferenceError(StandardError): ...
class SyntaxError(StandardError):
msg = ... # type: str
lineno = ... # type: int
offset = ... # type: int
text = ... # type: str
class IndentationError(SyntaxError): ...
class TabError(IndentationError): ...
class SystemError(StandardError): ...
class TypeError(StandardError): ...
class UnboundLocalError(NameError): ...
class UnicodeError(ValueError): ...
class UnicodeDecodeError(UnicodeError): ...
class UnicodeEncodeError(UnicodeError): ...
class UnicodeTranslateError(UnicodeError): ...
class ZeroDivisionError(ArithmeticError): ...
class Warning(Exception): ...
class UserWarning(Warning): ...
class DeprecationWarning(Warning): ...
class SyntaxWarning(Warning): ...
class RuntimeWarning(Warning): ...
class FutureWarning(Warning): ...
class PendingDeprecationWarning(Warning): ...
class ImportWarning(Warning): ...
class UnicodeWarning(Warning): ...
class BytesWarning(Warning): ...
class ResourceWarning(Warning): ...
def eval(s: str, globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> Any: ...
def exec(object: str,
globals: Dict[str, Any] = None,
locals: Dict[str, Any] = None) -> Any: ... # TODO code object as source
def cmp(x: Any, y: Any) -> int: ...
def execfile(filename: str, globals: Dict[str, Any] = None, locals: Dict[str, Any] = None) -> None: ...
class file(BinaryIO):
@overload
def __init__(self, file: str, mode: str = 'r', buffering: int = ...) -> None: ...
@overload
def __init__(self, file: unicode, mode: str = 'r', buffering: int = ...) -> None: ...
@overload
def __init__(file: int, mode: str = 'r', buffering: int = ...) -> None: ...
def __iter__(self) -> Iterator[str]: ...
def read(self, n: int = ...) -> str: ...
def __enter__(self) -> BinaryIO: ...
def __exit__(self, t: type = None, exc: BaseException = None, tb: Any = None) -> bool: ...
def flush(self) -> None: ...
def fileno(self) -> int: ...
def isatty(self) -> bool: ...
def close(self) -> None: ...
def readable(self) -> bool: ...
def writable(self) -> bool: ...
def seekable(self) -> bool: ...
def seek(self, offset: int, whence: int = ...) -> None: ...
def tell(self) -> int: ...
def readline(self, limit: int = ...) -> str: ...
def readlines(self, hint: int = ...) -> List[str]: ...
def write(self, data: str) -> None: ...
def writelines(self, data: Iterable[str]) -> None: ...
def truncate(self, pos: int = ...) -> int: ...
# Very old builtins
def apply(func: Callable[..., _T], args: Sequence[Any] = None, kwds: Mapping[str, Any] = None) -> _T: ...
_N = TypeVar('_N', bool, int, float, complex)
def coerce(x: _N, y: _N) -> Tuple[_N, _N]: ...

13
stdlib/2/__future__.pyi Normal file
View File

@@ -0,0 +1,13 @@
from sys import _version_info
class _Feature:
def getOptionalRelease(self) -> _version_info: ...
def getMandatoryRelease(self) -> _version_info: ...
absolute_import = ... # type: _Feature
division = ... # type: _Feature
generators = ... # type: _Feature
nested_scopes = ... # type: _Feature
print_function = ... # type: _Feature
unicode_literals = ... # type: _Feature
with_statement = ... # type: _Feature

328
stdlib/2/_ast.pyi Normal file
View File

@@ -0,0 +1,328 @@
import typing
from typing import Optional, Union
__version__ = ... # type: str
PyCF_ONLY_AST = ... # type: int
identifier = str
class AST:
_attributes = ... # type: typing.Tuple[str, ...]
_fields = ... # type: typing.Tuple[str, ...]
def __init__(self, *args, **kwargs) -> None: ...
class mod(AST):
...
class Module(mod):
body = ... # type: typing.List[stmt]
class Interactive(mod):
body = ... # type: typing.List[stmt]
class Expression(mod):
body = ... # type: expr
class Suite(mod):
body = ... # type: typing.List[stmt]
class stmt(AST):
lineno = ... # type: int
col_offset = ... # type: int
class FunctionDef(stmt):
name = ... # type: identifier
args = ... # type: arguments
body = ... # type: typing.List[stmt]
decorator_list = ... # type: typing.List[expr]
class ClassDef(stmt):
name = ... # type: identifier
bases = ... # type: typing.List[expr]
body = ... # type: typing.List[stmt]
decorator_list = ... # type: typing.List[expr]
class Return(stmt):
value = ... # type: Optional[expr]
class Delete(stmt):
targets = ... # type: typing.List[expr]
class Assign(stmt):
targets = ... # type: typing.List[expr]
value = ... # type: expr
class AugAssign(stmt):
target = ... # type: expr
op = ... # type: operator
value = ... # type: expr
class Print(stmt):
dest = ... # type: Optional[expr]
values = ... # type: typing.List[expr]
nl = ... # type: bool
class For(stmt):
target = ... # type: expr
iter = ... # type: expr
body = ... # type: typing.List[stmt]
orelse = ... # type: typing.List[stmt]
class While(stmt):
test = ... # type: expr
body = ... # type: typing.List[stmt]
orelse = ... # type: typing.List[stmt]
class If(stmt):
test = ... # type: expr
body = ... # type: typing.List[stmt]
orelse = ... # type: typing.List[stmt]
class With(stmt):
context_expr = ... # type: expr
optional_vars = ... # type: Optional[expr]
body = ... # type: typing.List[stmt]
class Raise(stmt):
type = ... # type: Optional[expr]
inst = ... # type: Optional[expr]
tback = ... # type: Optional[expr]
class TryExcept(stmt):
body = ... # type: typing.List[stmt]
handlers = ... # type: typing.List[ExceptHandler]
orelse = ... # type: typing.List[stmt]
class TryFinally(stmt):
body = ... # type: typing.List[stmt]
finalbody = ... # type: typing.List[stmt]
class Assert(stmt):
test = ... # type: expr
msg = ... # type: Optional[expr]
class Import(stmt):
names = ... # type: typing.List[alias]
class ImportFrom(stmt):
module = ... # type: Optional[identifier]
names = ... # type: typing.List[alias]
level = ... # type: Optional[int]
class Exec(stmt):
body = ... # type: expr
globals = ... # type: Optional[expr]
locals = ... # type: Optional[expr]
class Global(stmt):
names = ... # type: typing.List[identifier]
class Expr(stmt):
value = ... # type: expr
class Pass(stmt): ...
class Break(stmt): ...
class Continue(stmt): ...
class slice(AST):
...
_slice = slice # this lets us type the variable named 'slice' below
class Slice(slice):
lower = ... # type: Optional[expr]
upper = ... # type: Optional[expr]
step = ... # type: Optional[expr]
class ExtSlice(slice):
dims = ... # type: typing.List[slice]
class Index(slice):
value = ... # type: expr
class Ellipsis(slice): ...
class expr(AST):
lineno = ... # type: int
col_offset = ... # type: int
class BoolOp(expr):
op = ... # type: boolop
values = ... # type: typing.List[expr]
class BinOp(expr):
left = ... # type: expr
op = ... # type: operator
right = ... # type: expr
class UnaryOp(expr):
op = ... # type: unaryop
operand = ... # type: expr
class Lambda(expr):
args = ... # type: arguments
body = ... # type: expr
class IfExp(expr):
test = ... # type: expr
body = ... # type: expr
orelse = ... # type: expr
class Dict(expr):
keys = ... # type: typing.List[expr]
values = ... # type: typing.List[expr]
class Set(expr):
elts = ... # type: typing.List[expr]
class ListComp(expr):
elt = ... # type: expr
generators = ... # type: typing.List[comprehension]
class SetComp(expr):
elt = ... # type: expr
generators = ... # type: typing.List[comprehension]
class DictComp(expr):
key = ... # type: expr
value = ... # type: expr
generators = ... # type: typing.List[comprehension]
class GeneratorExp(expr):
elt = ... # type: expr
generators = ... # type: typing.List[comprehension]
class Yield(expr):
value = ... # type: Optional[expr]
class Compare(expr):
left = ... # type: expr
ops = ... # type: typing.List[cmpop]
comparators = ... # type: typing.List[expr]
class Call(expr):
func = ... # type: expr
args = ... # type: typing.List[expr]
keywords = ... # type: typing.List[keyword]
starargs = ... # type: Optional[expr]
kwargs = ... # type: Optional[expr]
class Repr(expr):
value = ... # type: expr
class Num(expr):
n = ... # type: Union[int, float]
class Str(expr):
s = ... # type: str
class Attribute(expr):
value = ... # type: expr
attr = ... # type: identifier
ctx = ... # type: expr_context
class Subscript(expr):
value = ... # type: expr
slice = ... # type: _slice
ctx = ... # type: expr_context
class Name(expr):
id = ... # type: identifier
ctx = ... # type: expr_context
class List(expr):
elts = ... # type: typing.List[expr]
ctx = ... # type: expr_context
class Tuple(expr):
elts = ... # type: typing.List[expr]
ctx = ... # type: expr_context
class expr_context(AST):
...
class AugLoad(expr_context): ...
class AugStore(expr_context): ...
class Del(expr_context): ...
class Load(expr_context): ...
class Param(expr_context): ...
class Store(expr_context): ...
class boolop(AST):
...
class And(boolop): ...
class Or(boolop): ...
class operator(AST):
...
class Add(operator): ...
class BitAnd(operator): ...
class BitOr(operator): ...
class BitXor(operator): ...
class Div(operator): ...
class FloorDiv(operator): ...
class LShift(operator): ...
class Mod(operator): ...
class Mult(operator): ...
class Pow(operator): ...
class RShift(operator): ...
class Sub(operator): ...
class unaryop(AST):
...
class Invert(unaryop): ...
class Not(unaryop): ...
class UAdd(unaryop): ...
class USub(unaryop): ...
class cmpop(AST):
...
class Eq(cmpop): ...
class Gt(cmpop): ...
class GtE(cmpop): ...
class In(cmpop): ...
class Is(cmpop): ...
class IsNot(cmpop): ...
class Lt(cmpop): ...
class LtE(cmpop): ...
class NotEq(cmpop): ...
class NotIn(cmpop): ...
class comprehension(AST):
target = ... # type: expr
iter = ... # type: expr
ifs = ... # type: typing.List[expr]
class ExceptHandler(AST):
type = ... # type: Optional[expr]
name = ... # type: Optional[expr]
body = ... # type: typing.List[stmt]
lineno = ... # type: int
col_offset = ... # type: int
class arguments(AST):
args = ... # type: typing.List[expr]
vararg = ... # type: Optional[identifier]
kwarg = ... # type: Optional[identifier]
defaults = ... # type: typing.List[expr]
class keyword(AST):
arg = ... # type: identifier
value = ... # type: expr
class alias(AST):
name = ... # type: identifier
asname = ... # type: Optional[identifier]

55
stdlib/2/_codecs.pyi Normal file
View File

@@ -0,0 +1,55 @@
"""Stub file for the '_codecs' module."""
from typing import Any, AnyStr, Callable, Tuple, Optional
import codecs
# For convenience:
_Handler = Callable[[Exception], Tuple[unicode, int]]
# Not exposed. In Python 2, this is defined in unicode.c:
class _EncodingMap(object):
def size(self) -> int: ...
def register(search_function: Callable[[str], Any]) -> None: ...
def register_error(errors: str, handler: _Handler) -> None: ...
def lookup(a: str) -> codecs.CodecInfo: ...
def lookup_error(a: str) -> _Handler: ...
def decode(obj: Any, encoding:str = ..., errors:str = ...) -> Any: ...
def encode(obj: Any, encoding:str = ..., errors:str = ...) -> Any: ...
def charmap_build(a: unicode) -> _EncodingMap: ...
def ascii_decode(data: AnyStr, errors:str = ...) -> Tuple[unicode, int]: ...
def ascii_encode(data: AnyStr, errors:str = ...) -> Tuple[str, int]: ...
def charbuffer_encode(data: AnyStr, errors: str = ...) -> Tuple[str, int]: ...
def charmap_decode(data: AnyStr, errors: str = ..., mapping: Optional[_EncodingMap] = ...) -> Tuple[unicode, int]: ...
def charmap_encode(data: AnyStr, errors: str, mapping: Optional[_EncodingMap] = ...) -> Tuple[str, int]: ...
def escape_decode(data: AnyStr, errors:str = ...) -> Tuple[unicode, int]: ...
def escape_encode(data: AnyStr, errors:str = ...) -> Tuple[str, int]: ...
def latin_1_decode(data: AnyStr, errors:str = ...) -> Tuple[unicode, int]: ...
def latin_1_encode(data: AnyStr, errors:str = ...) -> Tuple[str, int]: ...
def raw_unicode_escape_decode(data: AnyStr, errors:str = ...) -> Tuple[unicode, int]: ...
def raw_unicode_escape_encode(data: AnyStr, errors:str = ...) -> Tuple[str, int]: ...
def readbuffer_encode(data: AnyStr, errors:str = ...) -> Tuple[str, int]: ...
def unicode_escape_decode(data: AnyStr, errors:str = ...) -> Tuple[unicode, int]: ...
def unicode_escape_encode(data: AnyStr, errors:str = ...) -> Tuple[str, int]: ...
def unicode_internal_decode(data: AnyStr, errors:str = ...) -> Tuple[unicode, int]: ...
def unicode_internal_encode(data: AnyStr, errors:str = ...) -> Tuple[str, int]: ...
def utf_16_be_decode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[unicode, int]: ...
def utf_16_be_encode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[str, int]: ...
def utf_16_decode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[unicode, int]: ...
def utf_16_encode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[str, int]: ...
def utf_16_ex_decode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[unicode, int]: ...
def utf_16_le_decode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[unicode, int]: ...
def utf_16_le_encode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[str, int]: ...
def utf_32_be_decode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[unicode, int]: ...
def utf_32_be_encode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[str, int]: ...
def utf_32_decode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[unicode, int]: ...
def utf_32_encode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[str, int]: ...
def utf_32_ex_decode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[unicode, int]: ...
def utf_32_le_decode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[unicode, int]: ...
def utf_32_le_encode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[str, int]: ...
def utf_7_decode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[unicode, int]: ...
def utf_7_encode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[str, int]: ...
def utf_8_decode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[unicode, int]: ...
def utf_8_encode(data: AnyStr, errors:str = ..., final:int = ...) -> Tuple[str, int]: ...

41
stdlib/2/_collections.pyi Normal file
View File

@@ -0,0 +1,41 @@
"""Stub file for the '_collections' module."""
from typing import Any, Generic, Iterator, TypeVar, Optional, Union
class defaultdict(dict):
default_factory = ... # type: None
def __init__(self, default: Any = ..., init: Any = ...) -> None: ...
def __missing__(self, key) -> Any:
raise KeyError()
def __copy__(self) -> "defaultdict": ...
def copy(self) -> "defaultdict": ...
_T = TypeVar('_T')
_T2 = TypeVar('_T2')
class deque(Generic[_T]):
maxlen = ... # type: Optional[int]
def __init__(self, iterable: Iterator[_T] = ..., maxlen: int = ...) -> None: ...
def append(self, x: _T) -> None: ...
def appendleft(self, x: _T) -> None: ...
def clear(self) -> None: ...
def count(self, x: Any) -> int: ...
def extend(self, iterable: Iterator[_T]) -> None: ...
def extendleft(self, iterable: Iterator[_T]) -> None: ...
def pop(self) -> _T:
raise IndexError()
def popleft(self) -> _T:
raise IndexError()
def remove(self, value: _T) -> None:
raise IndexError()
def reverse(self) -> None: ...
def rotate(self, n: int = ...) -> None: ...
def __contains__(self, o: Any) -> bool: ...
def __copy__(self) -> "deque[_T]": ...
def __getitem__(self, i: int) -> _T:
raise IndexError()
def __iadd__(self, other: "deque[_T2]") -> "deque[Union[_T, _T2]]": ...
def __iter__(self) -> Iterator[_T]: ...
def __len__(self) -> int: ...
def __reversed__(self) -> Iterator[_T]: ...
def __setitem__(self, i: int, x: _T) -> None: ...

20
stdlib/2/_functools.pyi Normal file
View File

@@ -0,0 +1,20 @@
"""Stub file for the '_functools' module."""
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Tuple, overload
_T = TypeVar("_T")
_S = TypeVar("_S")
@overload
def reduce(function: Callable[[_T, _T], _T],
sequence: Iterable[_T]) -> _T: ...
@overload
def reduce(function: Callable[[_T, _S], _T],
sequence: Iterable[_S], initial: _T) -> _T: ...
class partial(object):
func = ... # type: Callable[..., Any]
args = ... # type: Tuple[Any, ...]
keywords = ... # type: Dict[str, Any]
def __init__(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...

34
stdlib/2/_hotshot.pyi Normal file
View File

@@ -0,0 +1,34 @@
"""Stub file for the '_hotshot' module."""
# This is an autogenerated file. It serves as a starting point
# for a more precise manual annotation of this module.
# Feel free to edit the source below, but remove this header when you do.
from typing import Any, List, Tuple, Dict, Generic
def coverage(a: str) -> Any: ...
def logreader(a: str) -> LogReaderType:
raise IOError()
raise RuntimeError()
def profiler(a: str, *args, **kwargs) -> Any:
raise IOError()
def resolution() -> tuple: ...
class LogReaderType(object):
def close(self) -> None: ...
def fileno(self) -> int:
raise ValueError()
class ProfilerType(object):
def addinfo(self, a: str, b: str) -> None: ...
def close(self) -> None: ...
def fileno(self) -> int:
raise ValueError()
def runcall(self, *args, **kwargs) -> Any: ...
def runcode(self, a, b, *args, **kwargs) -> Any:
raise TypeError()
def start(self) -> None: ...
def stop(self) -> None: ...

107
stdlib/2/_io.pyi Normal file
View File

@@ -0,0 +1,107 @@
from typing import Any, Optional, Iterable, Tuple, List, Union
DEFAULT_BUFFER_SIZE = ... # type: int
class BlockingIOError(IOError):
characters_written = ... # type: int
class UnsupportedOperation(ValueError, IOError): ...
class _IOBase(object):
closed = ... # type: bool
def __enter__(self) -> "_IOBase": ...
def __exit__(self, type, value, traceback) -> bool: ...
def __iter__(self) -> "_IOBase": ...
def _checkClosed(self) -> None: ...
def _checkReadable(self) -> None: ...
def _checkSeekable(self) -> None: ...
def _checkWritable(self) -> None: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def next(self) -> str: ...
def readable(self) -> bool: ...
def readline(self, limit: int = ...) -> str: ...
def readlines(self, hint: int = ...) -> List[str]: ...
def seek(self, offset: int, whence: int = ...) -> None: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, size: int = ...) -> int: ...
def writable(self) -> bool: ...
def writelines(self, lines: Iterable[str]) -> None: ...
class _BufferedIOBase(_IOBase):
def read1(self, n: int) -> str: ...
def read(self, n: int = ...) -> str: ...
def readinto(self, buffer: bytearray) -> int: ...
def write(self, s: str) -> int: ...
def detach(self) -> "_BufferedIOBase": ...
class BufferedRWPair(_BufferedIOBase):
def peek(self, n: int = ...) -> str: ...
class BufferedRandom(_BufferedIOBase):
name = ... # type: str
raw = ... # type: _IOBase
mode = ... # type: str
def peek(self, n: int = ...) -> str: ...
class BufferedReader(_BufferedIOBase):
name = ... # type: str
raw = ... # type: _IOBase
mode = ... # type: str
def peek(self, n: int = ...) -> str: ...
class BufferedWriter(_BufferedIOBase):
name = ... # type: str
raw = ... # type: _IOBase
mode = ... # type: str
class BytesIO(_BufferedIOBase):
def __setstate__(self, tuple) -> None: ...
def __getstate__(self) -> tuple: ...
def getvalue(self) -> str: ...
class _RawIOBase(_IOBase):
def readall(self) -> str: ...
def read(self, n: int = ...) -> str: ...
class FileIO(_RawIOBase):
mode = ... # type: str
closefd = ... # type: bool
def readinto(self, buffer: bytearray)-> int: ...
def write(self, pbuf: str) -> int: ...
class IncrementalNewlineDecoder(object):
newlines = ... # type: Union[str, unicode]
def decode(self, input, final) -> Any: ...
def getstate(self) -> Tuple[Any, int]: ...
def setstate(self, state: Tuple[Any, int]) -> None: ...
def reset(self) -> None: ...
class _TextIOBase(_IOBase):
errors = ... # type: Optional[str]
newlines = ... # type: Union[str, unicode]
encoding = ... # type: Optional[str]
def read(self, n: int = ...) -> str: ...
def write(self) -> None:
raise UnsupportedOperation
def detach(self) -> None:
raise UnsupportedOperation
class StringIO(_TextIOBase):
line_buffering = ... # type: bool
def getvalue(self) -> str: ...
def __setstate__(self, state: tuple) -> None: ...
def __getstate__(self) -> tuple: ...
class TextIOWrapper(_TextIOBase):
name = ... # type: str
line_buffering = ... # type: bool
buffer = ... # type: str
_CHUNK_SIZE = ... # type: int
def open(file: Union[int, str], mode: str = ...) -> _IOBase: ...

19
stdlib/2/_json.pyi Normal file
View File

@@ -0,0 +1,19 @@
"""Stub file for the '_json' module."""
# This is an autogenerated file. It serves as a starting point
# for a more precise manual annotation of this module.
# Feel free to edit the source below, but remove this header when you do.
from typing import Any, List, Tuple, Dict, Generic
def encode_basestring_ascii(*args, **kwargs) -> str:
raise TypeError()
def scanstring(a, b, *args, **kwargs) -> tuple:
raise TypeError()
class Encoder(object):
pass
class Scanner(object):
pass

13
stdlib/2/_md5.pyi Normal file
View File

@@ -0,0 +1,13 @@
blocksize = ... # type: int
digest_size = ... # type: int
class MD5Type(object):
name = ... # type: str
block_size = ... # type: int
digest_size = ... # type: int
def copy(self) -> "MD5Type": ...
def digest(self) -> str: ...
def hexdigest(self) -> str: ...
def update(self, arg: str) -> None: ...
def new(arg: str = ...) -> MD5Type: ...

13
stdlib/2/_random.pyi Normal file
View File

@@ -0,0 +1,13 @@
from typing import Tuple
# Actually Tuple[(int,) * 625]
_State = Tuple[int, ...]
class Random(object):
def __init__(self, seed: object = ...) -> None: ...
def seed(self, x: object = ...) -> None: ...
def getstate(self) -> _State: ...
def setstate(self, state: _State) -> None: ...
def random(self) -> float: ...
def getrandbits(self, k: int) -> int: ...
def jumpahead(self, i: int) -> None: ...

15
stdlib/2/_sha.pyi Normal file
View File

@@ -0,0 +1,15 @@
blocksize = ... # type: int
block_size = ... # type: int
digest_size = ... # type: int
class sha(object): # not actually exposed
name = ... # type: str
block_size = ... # type: int
digest_size = ... # type: int
digestsize = ... # type: int
def copy(self) -> "sha": ...
def digest(self) -> str: ...
def hexdigest(self) -> str: ...
def update(self, arg: str) -> None: ...
def new(arg: str = ...) -> sha: ...

23
stdlib/2/_sha256.pyi Normal file
View File

@@ -0,0 +1,23 @@
from typing import Optional
class sha224(object):
name = ... # type: str
block_size = ... # type: int
digest_size = ... # type: int
digestsize = ... # type: int
def __init__(self, init: Optional[str]) -> None: ...
def copy(self) -> "sha224": ...
def digest(self) -> str: ...
def hexdigest(self) -> str: ...
def update(self, arg: str) -> None: ...
class sha256(object):
name = ... # type: str
block_size = ... # type: int
digest_size = ... # type: int
digestsize = ... # type: int
def __init__(self, init: Optional[str]) -> None: ...
def copy(self) -> "sha256": ...
def digest(self) -> str: ...
def hexdigest(self) -> str: ...
def update(self, arg: str) -> None: ...

23
stdlib/2/_sha512.pyi Normal file
View File

@@ -0,0 +1,23 @@
from typing import Optional
class sha384(object):
name = ... # type: str
block_size = ... # type: int
digest_size = ... # type: int
digestsize = ... # type: int
def __init__(self, init: Optional[str]) -> None: ...
def copy(self) -> "sha384": ...
def digest(self) -> str: ...
def hexdigest(self) -> str: ...
def update(self, arg: str) -> None: ...
class sha512(object):
name = ... # type: str
block_size = ... # type: int
digest_size = ... # type: int
digestsize = ... # type: int
def __init__(self, init: Optional[str]) -> None: ...
def copy(self) -> "sha512": ...
def digest(self) -> str: ...
def hexdigest(self) -> str: ...
def update(self, arg: str) -> None: ...

287
stdlib/2/_socket.pyi Normal file
View File

@@ -0,0 +1,287 @@
from typing import Tuple, Union, IO, Any, Optional, overload
AF_APPLETALK = ... # type: int
AF_ASH = ... # type: int
AF_ATMPVC = ... # type: int
AF_ATMSVC = ... # type: int
AF_AX25 = ... # type: int
AF_BLUETOOTH = ... # type: int
AF_BRIDGE = ... # type: int
AF_DECnet = ... # type: int
AF_ECONET = ... # type: int
AF_INET = ... # type: int
AF_INET6 = ... # type: int
AF_IPX = ... # type: int
AF_IRDA = ... # type: int
AF_KEY = ... # type: int
AF_LLC = ... # type: int
AF_NETBEUI = ... # type: int
AF_NETLINK = ... # type: int
AF_NETROM = ... # type: int
AF_PACKET = ... # type: int
AF_PPPOX = ... # type: int
AF_ROSE = ... # type: int
AF_ROUTE = ... # type: int
AF_SECURITY = ... # type: int
AF_SNA = ... # type: int
AF_TIPC = ... # type: int
AF_UNIX = ... # type: int
AF_UNSPEC = ... # type: int
AF_WANPIPE = ... # type: int
AF_X25 = ... # type: int
AI_ADDRCONFIG = ... # type: int
AI_ALL = ... # type: int
AI_CANONNAME = ... # type: int
AI_NUMERICHOST = ... # type: int
AI_NUMERICSERV = ... # type: int
AI_PASSIVE = ... # type: int
AI_V4MAPPED = ... # type: int
BDADDR_ANY = ... # type: str
BDADDR_LOCAL = ... # type: str
BTPROTO_HCI = ... # type: int
BTPROTO_L2CAP = ... # type: int
BTPROTO_RFCOMM = ... # type: int
BTPROTO_SCO = ... # type: int
EAI_ADDRFAMILY = ... # type: int
EAI_AGAIN = ... # type: int
EAI_BADFLAGS = ... # type: int
EAI_FAIL = ... # type: int
EAI_FAMILY = ... # type: int
EAI_MEMORY = ... # type: int
EAI_NODATA = ... # type: int
EAI_NONAME = ... # type: int
EAI_OVERFLOW = ... # type: int
EAI_SERVICE = ... # type: int
EAI_SOCKTYPE = ... # type: int
EAI_SYSTEM = ... # type: int
EBADF = ... # type: int
EINTR = ... # type: int
HCI_DATA_DIR = ... # type: int
HCI_FILTER = ... # type: int
HCI_TIME_STAMP = ... # type: int
INADDR_ALLHOSTS_GROUP = ... # type: int
INADDR_ANY = ... # type: int
INADDR_BROADCAST = ... # type: int
INADDR_LOOPBACK = ... # type: int
INADDR_MAX_LOCAL_GROUP = ... # type: int
INADDR_NONE = ... # type: int
INADDR_UNSPEC_GROUP = ... # type: int
IPPORT_RESERVED = ... # type: int
IPPORT_USERRESERVED = ... # type: int
IPPROTO_AH = ... # type: int
IPPROTO_DSTOPTS = ... # type: int
IPPROTO_EGP = ... # type: int
IPPROTO_ESP = ... # type: int
IPPROTO_FRAGMENT = ... # type: int
IPPROTO_GRE = ... # type: int
IPPROTO_HOPOPTS = ... # type: int
IPPROTO_ICMP = ... # type: int
IPPROTO_ICMPV6 = ... # type: int
IPPROTO_IDP = ... # type: int
IPPROTO_IGMP = ... # type: int
IPPROTO_IP = ... # type: int
IPPROTO_IPIP = ... # type: int
IPPROTO_IPV6 = ... # type: int
IPPROTO_NONE = ... # type: int
IPPROTO_PIM = ... # type: int
IPPROTO_PUP = ... # type: int
IPPROTO_RAW = ... # type: int
IPPROTO_ROUTING = ... # type: int
IPPROTO_RSVP = ... # type: int
IPPROTO_TCP = ... # type: int
IPPROTO_TP = ... # type: int
IPPROTO_UDP = ... # type: int
IPV6_CHECKSUM = ... # type: int
IPV6_DSTOPTS = ... # type: int
IPV6_HOPLIMIT = ... # type: int
IPV6_HOPOPTS = ... # type: int
IPV6_JOIN_GROUP = ... # type: int
IPV6_LEAVE_GROUP = ... # type: int
IPV6_MULTICAST_HOPS = ... # type: int
IPV6_MULTICAST_IF = ... # type: int
IPV6_MULTICAST_LOOP = ... # type: int
IPV6_NEXTHOP = ... # type: int
IPV6_PKTINFO = ... # type: int
IPV6_RECVDSTOPTS = ... # type: int
IPV6_RECVHOPLIMIT = ... # type: int
IPV6_RECVHOPOPTS = ... # type: int
IPV6_RECVPKTINFO = ... # type: int
IPV6_RECVRTHDR = ... # type: int
IPV6_RECVTCLASS = ... # type: int
IPV6_RTHDR = ... # type: int
IPV6_RTHDRDSTOPTS = ... # type: int
IPV6_RTHDR_TYPE_0 = ... # type: int
IPV6_TCLASS = ... # type: int
IPV6_UNICAST_HOPS = ... # type: int
IPV6_V6ONLY = ... # type: int
IP_ADD_MEMBERSHIP = ... # type: int
IP_DEFAULT_MULTICAST_LOOP = ... # type: int
IP_DEFAULT_MULTICAST_TTL = ... # type: int
IP_DROP_MEMBERSHIP = ... # type: int
IP_HDRINCL = ... # type: int
IP_MAX_MEMBERSHIPS = ... # type: int
IP_MULTICAST_IF = ... # type: int
IP_MULTICAST_LOOP = ... # type: int
IP_MULTICAST_TTL = ... # type: int
IP_OPTIONS = ... # type: int
IP_RECVOPTS = ... # type: int
IP_RECVRETOPTS = ... # type: int
IP_RETOPTS = ... # type: int
IP_TOS = ... # type: int
IP_TTL = ... # type: int
MSG_CTRUNC = ... # type: int
MSG_DONTROUTE = ... # type: int
MSG_DONTWAIT = ... # type: int
MSG_EOR = ... # type: int
MSG_OOB = ... # type: int
MSG_PEEK = ... # type: int
MSG_TRUNC = ... # type: int
MSG_WAITALL = ... # type: int
MethodType = ... # type: type
NETLINK_DNRTMSG = ... # type: int
NETLINK_FIREWALL = ... # type: int
NETLINK_IP6_FW = ... # type: int
NETLINK_NFLOG = ... # type: int
NETLINK_ROUTE = ... # type: int
NETLINK_USERSOCK = ... # type: int
NETLINK_XFRM = ... # type: int
NI_DGRAM = ... # type: int
NI_MAXHOST = ... # type: int
NI_MAXSERV = ... # type: int
NI_NAMEREQD = ... # type: int
NI_NOFQDN = ... # type: int
NI_NUMERICHOST = ... # type: int
NI_NUMERICSERV = ... # type: int
PACKET_BROADCAST = ... # type: int
PACKET_FASTROUTE = ... # type: int
PACKET_HOST = ... # type: int
PACKET_LOOPBACK = ... # type: int
PACKET_MULTICAST = ... # type: int
PACKET_OTHERHOST = ... # type: int
PACKET_OUTGOING = ... # type: int
PF_PACKET = ... # type: int
SHUT_RD = ... # type: int
SHUT_RDWR = ... # type: int
SHUT_WR = ... # type: int
SOCK_DGRAM = ... # type: int
SOCK_RAW = ... # type: int
SOCK_RDM = ... # type: int
SOCK_SEQPACKET = ... # type: int
SOCK_STREAM = ... # type: int
SOL_HCI = ... # type: int
SOL_IP = ... # type: int
SOL_SOCKET = ... # type: int
SOL_TCP = ... # type: int
SOL_TIPC = ... # type: int
SOL_UDP = ... # type: int
SOMAXCONN = ... # type: int
SO_ACCEPTCONN = ... # type: int
SO_BROADCAST = ... # type: int
SO_DEBUG = ... # type: int
SO_DONTROUTE = ... # type: int
SO_ERROR = ... # type: int
SO_KEEPALIVE = ... # type: int
SO_LINGER = ... # type: int
SO_OOBINLINE = ... # type: int
SO_RCVBUF = ... # type: int
SO_RCVLOWAT = ... # type: int
SO_RCVTIMEO = ... # type: int
SO_REUSEADDR = ... # type: int
SO_REUSEPORT = ... # type: int
SO_SNDBUF = ... # type: int
SO_SNDLOWAT = ... # type: int
SO_SNDTIMEO = ... # type: int
SO_TYPE = ... # type: int
SSL_ERROR_EOF = ... # type: int
SSL_ERROR_INVALID_ERROR_CODE = ... # type: int
SSL_ERROR_SSL = ... # type: int
SSL_ERROR_SYSCALL = ... # type: int
SSL_ERROR_WANT_CONNECT = ... # type: int
SSL_ERROR_WANT_READ = ... # type: int
SSL_ERROR_WANT_WRITE = ... # type: int
SSL_ERROR_WANT_X509_LOOKUP = ... # type: int
SSL_ERROR_ZERO_RETURN = ... # type: int
TCP_CORK = ... # type: int
TCP_DEFER_ACCEPT = ... # type: int
TCP_INFO = ... # type: int
TCP_KEEPCNT = ... # type: int
TCP_KEEPIDLE = ... # type: int
TCP_KEEPINTVL = ... # type: int
TCP_LINGER2 = ... # type: int
TCP_MAXSEG = ... # type: int
TCP_NODELAY = ... # type: int
TCP_QUICKACK = ... # type: int
TCP_SYNCNT = ... # type: int
TCP_WINDOW_CLAMP = ... # type: int
TIPC_ADDR_ID = ... # type: int
TIPC_ADDR_NAME = ... # type: int
TIPC_ADDR_NAMESEQ = ... # type: int
TIPC_CFG_SRV = ... # type: int
TIPC_CLUSTER_SCOPE = ... # type: int
TIPC_CONN_TIMEOUT = ... # type: int
TIPC_CRITICAL_IMPORTANCE = ... # type: int
TIPC_DEST_DROPPABLE = ... # type: int
TIPC_HIGH_IMPORTANCE = ... # type: int
TIPC_IMPORTANCE = ... # type: int
TIPC_LOW_IMPORTANCE = ... # type: int
TIPC_MEDIUM_IMPORTANCE = ... # type: int
TIPC_NODE_SCOPE = ... # type: int
TIPC_PUBLISHED = ... # type: int
TIPC_SRC_DROPPABLE = ... # type: int
TIPC_SUBSCR_TIMEOUT = ... # type: int
TIPC_SUB_CANCEL = ... # type: int
TIPC_SUB_PORTS = ... # type: int
TIPC_SUB_SERVICE = ... # type: int
TIPC_TOP_SRV = ... # type: int
TIPC_WAIT_FOREVER = ... # type: int
TIPC_WITHDRAWN = ... # type: int
TIPC_ZONE_SCOPE = ... # type: int
# PyCapsule
CAPI = ... # type: Any
has_ipv6 = ... # type: bool
class error(IOError): ...
class gaierror(error): ...
class timeout(error): ...
class SocketType(object):
family = ... # type: int
type = ... # type: int
proto = ... # type: int
timeout = ... # type: float
def __init__(self, family: int = ..., type: int = ..., proto: int = ...) -> None: ...
def accept(self) -> Tuple['SocketType', tuple]: ...
def bind(self, address: tuple) -> None: ...
def close(self) -> None: ...
def connect(self, address: tuple) -> None:
raise gaierror
raise timeout
def connect_ex(self, address: tuple) -> int: ...
def dup(self) -> "SocketType": ...
def fileno(self) -> int: ...
def getpeername(self) -> tuple: ...
def getsockname(self) -> tuple: ...
def getsockopt(self, level: int, option: int, buffersize: int = ...) -> str: ...
def gettimeout(self) -> float: ...
def listen(self, backlog: int) -> None:
raise error
def makefile(self, mode: str = ..., buffersize: int = ...) -> IO[Any]: ...
def recv(self, buffersize: int, flags: int = ...) -> str: ...
def recv_into(self, buffer: bytearray, nbytes: int = ..., flags: int = ...) -> int: ...
def recvfrom(self, buffersize: int, flags: int = ...) -> tuple:
raise error
def recvfrom_into(self, buffer: bytearray, nbytes: int = ...,
flags: int = ...) -> int: ...
def send(self, data: str, flags: int =...) -> int: ...
def sendall(self, data: str, flags: int = ...) -> None: ...
@overload
def sendto(self, data: str, address: tuple) -> int: ...
@overload
def sendto(self, data: str, flags: int, address: tuple) -> int: ...
def setblocking(self, flag: bool) -> None: ...
def setsockopt(self, level: int, option: int, value: Union[int, str]) -> None: ...
def settimeout(self, value: Optional[float]) -> None: ...
def shutdown(self, flag: int) -> None: ...

53
stdlib/2/_sre.pyi Normal file
View File

@@ -0,0 +1,53 @@
"""Stub file for the '_sre' module."""
from typing import Any, Union, Iterable, Optional, Mapping, Sequence, Dict, List, Tuple, overload
CODESIZE = ... # type: int
MAGIC = ... # type: int
MAXREPEAT = ... # type: long
copyright = ... # type: str
class SRE_Match(object):
def start(self, group: int = ...) -> int:
raise IndexError()
def end(self, group: int = ...) -> int:
raise IndexError()
def expand(self, s: str) -> Any: ...
@overload
def group(self) -> str: ...
@overload
def group(self, group:int = ...) -> Optional[str]: ...
def groupdict(self) -> Dict[int, Optional[str]]: ...
def groups(self) -> Tuple[Optional[str]]: ...
def span(self) -> Tuple[int, int]:
raise IndexError()
class SRE_Scanner(object):
pattern = ... # type: str
def match(self) -> SRE_Match: ...
def search(self) -> SRE_Match: ...
class SRE_Pattern(object):
pattern = ... # type: str
flags = ... # type: int
groups = ... # type: int
groupindex = ... # type: Mapping[int, int]
indexgroup = ... # type: Sequence[int]
def findall(self, source: str, pos:int = ..., endpos:int = ...) -> List[Union[tuple, str]]: ...
def finditer(self, source: str, pos: int = ..., endpos:int = ...) -> Iterable[Union[tuple, str]]: ...
def match(self, pattern, pos: int = ..., endpos:int = ...) -> SRE_Match: ...
def scanner(self, s: str, start: int = ..., end: int = ...) -> SRE_Scanner: ...
def search(self, pattern, pos: int = ..., endpos: int = ...) -> SRE_Match: ...
def split(self, source: str, maxsplit:int = ...) -> List[Optional[str]]: ...
def sub(self, repl: str, string: str, count:int = ...) -> tuple: ...
def subn(self, repl: str, string: str, count:int = ...) -> tuple: ...
def compile(pattern: str, flags: int, code: List[int],
groups:int = ...,
groupindex: Mapping[int, int] = ...,
indexgroup: Sequence[int] = ...) -> SRE_Pattern:
raise OverflowError()
def getcodesize() -> int: ...
def getlower(a: int, b: int) -> int: ...

22
stdlib/2/_struct.pyi Normal file
View File

@@ -0,0 +1,22 @@
"""Stub file for the '_struct' module."""
from typing import Any, AnyStr, Tuple
class error(Exception): ...
class Struct(object):
size = ... # type: int
format = ... # type: str
def __init__(self, fmt: str) -> None: ...
def pack_into(buffer: bytearray, offset: int, obj: Any) -> None: ...
def pack(self, *args) -> str: ...
def unpack(self, s:str) -> Tuple[Any]: ...
def unpack_from(self, buffer: bytearray, offset:int = ...) -> Tuple[Any]: ...
def _clearcache() -> None: ...
def calcsize(fmt: str) -> int: ...
def pack(fmt: AnyStr, obj: Any) -> str: ...
def pack_into(fmt: AnyStr, buffer: bytearray, offset: int, obj: Any) -> None: ...
def unpack(fmt: AnyStr, data: str) -> Tuple[Any]: ...
def unpack_from(fmt: AnyStr, buffer: bytearray, offset: int = ...) -> Tuple[Any]: ...

41
stdlib/2/_symtable.pyi Normal file
View File

@@ -0,0 +1,41 @@
from typing import List, Dict
CELL = ... # type: int
DEF_BOUND = ... # type: int
DEF_FREE = ... # type: int
DEF_FREE_CLASS = ... # type: int
DEF_GLOBAL = ... # type: int
DEF_IMPORT = ... # type: int
DEF_LOCAL = ... # type: int
DEF_PARAM = ... # type: int
FREE = ... # type: int
GLOBAL_EXPLICIT = ... # type: int
GLOBAL_IMPLICIT = ... # type: int
LOCAL = ... # type: int
OPT_BARE_EXEC = ... # type: int
OPT_EXEC = ... # type: int
OPT_IMPORT_STAR = ... # type: int
SCOPE_MASK = ... # type: int
SCOPE_OFF = ... # type: int
TYPE_CLASS = ... # type: int
TYPE_FUNCTION = ... # type: int
TYPE_MODULE = ... # type: int
USE = ... # type: int
class _symtable_entry(object):
...
class symtable(object):
children = ... # type: List[_symtable_entry]
id = ... # type: int
lineno = ... # type: int
name = ... # type: str
nested = ... # type: int
optimized = ... # type: int
symbols = ... # type: Dict[str, int]
type = ... # type: int
varnames = ... # type: List[str]
def __init__(src: str, filename: str, startstr: str) -> None: ...

11
stdlib/2/_warnings.pyi Normal file
View File

@@ -0,0 +1,11 @@
from typing import Any, List
default_action = ... # type: str
filters = ... # type: List[tuple]
once_registry = ... # type: dict
def warn(message: Warning, category:type = ..., stacklevel:int = ...) -> None: ...
def warn_explicit(message: Warning, category:type,
filename: str, lineno: int,
module:Any = ..., registry:dict = ...,
module_globals:dict = ...) -> None: ...

21
stdlib/2/_weakref.pyi Normal file
View File

@@ -0,0 +1,21 @@
from typing import Any, Callable, Generic, Optional, TypeVar
_T = TypeVar('_T')
class CallableProxyType(object): # "weakcallableproxy"
pass
class ProxyType(object): # "weakproxy"
pass
class ReferenceType(Generic[_T]):
# TODO rest of members
def __init__(self, o: _T, callback: Callable[[ReferenceType[_T]],
Any] = ...) -> None: ...
def __call__(self) -> Optional[_T]: ...
ref = ReferenceType
def getweakrefcount(object: Any) -> int: ...
def getweakrefs(object: Any) -> int: ...
def proxy(object: Any, callback: Callable[[Any], Any] = ...) -> None: ...

14
stdlib/2/_weakrefset.pyi Normal file
View File

@@ -0,0 +1,14 @@
from typing import Iterator, Any, Iterable, MutableSet, TypeVar, Generic
_T = TypeVar('_T')
class WeakSet(MutableSet[_T], Generic[_T]):
def __init__(self, data: Iterable[_T] = ...) -> None: ...
def add(self, x: _T) -> None: ...
def discard(self, x: _T) -> None: ...
def __contains__(self, x: Any) -> bool: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
# TODO: difference, difference_update, ...

39
stdlib/2/abc.pyi Normal file
View File

@@ -0,0 +1,39 @@
from typing import Any, Dict, Set, Union, Tuple
import _weakrefset
# mypy has special processing for ABCMeta and abstractmethod.
WeakSet = ... # type: _weakrefset.WeakSet
_InstanceType = ... # type: type
types = ... # type: module
def abstractmethod(funcobj: Any) -> Any: ...
class ABCMeta(type):
# TODO: FrozenSet
__abstractmethods__ = ... # type: Set[Any]
__doc__ = ... # type: str
_abc_cache = ... # type: _weakrefset.WeakSet
_abc_invalidation_counter = ... # type: int
_abc_negative_cache = ... # type: _weakrefset.WeakSet
_abc_negative_cache_version = ... # type: int
_abc_registry = ... # type: _weakrefset.WeakSet
def __init__(self, name: str, bases: Tuple[type, ...], namespace: Dict[Any, Any]) -> None: ...
def __instancecheck__(cls: "ABCMeta", instance: Any) -> Any: ...
def __subclasscheck__(cls: "ABCMeta", subclass: Any) -> Any: ...
def _dump_registry(cls: "ABCMeta", *args: Any, **kwargs: Any) -> None: ...
# TODO: subclass: Union["ABCMeta", type, Tuple[type, ...]]
def register(cls: "ABCMeta", subclass: Any) -> None: ...
class _C:
pass
# TODO: The real abc.abstractproperty inherits from "property".
class abstractproperty(object):
def __new__(cls, func: Any) -> Any: ...
__doc__ = ... # type: str
__isabstractmethod__ = ... # type: bool
doc = ... # type: Any
fdel = ... # type: Any
fget = ... # type: Any
fset = ... # type: Any

56
stdlib/2/array.pyi Normal file
View File

@@ -0,0 +1,56 @@
"""Stub file for the 'array' module."""
from typing import (Any, Generic, IO, Iterable, Sequence, TypeVar,
Union, overload, Iterator, Tuple, BinaryIO, List)
T = TypeVar('T')
class array(Generic[T]):
def __init__(self, typecode: str, init: Iterable[T] = ...) -> None: ...
def __add__(self, y: "array[T]") -> "array[T]": ...
def __contains__(self, y: Any) -> bool: ...
def __copy__(self) -> "array[T]": ...
def __deepcopy__(self) -> "array": ...
def __delitem__(self, y: Union[slice, int]) -> None: ...
def __delslice__(self, i: int, j: int) -> None: ...
@overload
def __getitem__(self, i: int) -> Any: ...
@overload
def __getitem__(self, s: slice) -> "array": ...
def __iadd__(self, y: "array[T]") -> "array[T]": ...
def __imul__(self, y: int) -> "array[T]": ...
def __iter__(self) -> Iterator[T]: ...
def __len__(self) -> int: ...
def __mul__(self, n: int) -> "array[T]": ...
def __rmul__(self, n: int) -> "array[T]": ...
@overload
def __setitem__(self, i: int, y: T) -> None: ...
@overload
def __setitem__(self, i: slice, y: "array[T]") -> None: ...
def append(self, x: T) -> None: ...
def buffer_info(self) -> Tuple[int, int]: ...
def byteswap(self) -> None:
raise RuntimeError()
def count(self) -> int: ...
def extend(self, x: Sequence[T]) -> None: ...
def fromlist(self, list: List[T]) -> None:
raise EOFError()
raise IOError()
def fromfile(self, f: BinaryIO, n: int) -> None: ...
def fromstring(self, s: str) -> None: ...
def fromunicode(self, u: unicode) -> None: ...
def index(self, x: T) -> int: ...
def insert(self, i: int, x: T) -> None: ...
def pop(self, i: int = ...) -> T: ...
def read(self, f: IO[str], n: int) -> None:
raise DeprecationWarning()
def remove(self, x: T) -> None: ...
def reverse(self) -> None: ...
def tofile(self, f: BinaryIO) -> None:
raise IOError()
def tolist(self) -> List[T]: ...
def tostring(self) -> str: ...
def tounicode(self) -> unicode: ...
def write(self, f: IO[str]) -> None:
raise DeprecationWarning()

45
stdlib/2/ast.pyi Normal file
View File

@@ -0,0 +1,45 @@
# Python 2.7 ast
import typing
from typing import Any, Iterator, Union
from _ast import (
Add, alias, And, arguments, Assert, Assign, AST, Attribute, AugAssign,
AugLoad, AugStore, BinOp, BitAnd, BitOr, BitXor, BoolOp, boolop, Break,
Call, ClassDef, cmpop, Compare, comprehension, Continue, Del, Delete, Dict,
DictComp, Div, Ellipsis, Eq, ExceptHandler, Exec, Expr, expr, Expression,
expr_context, ExtSlice, FloorDiv, For, FunctionDef, GeneratorExp, Global,
Gt, GtE, If, IfExp, Import, ImportFrom, In, Index, Interactive, Invert, Is,
IsNot, keyword, Lambda, List, ListComp, Load, LShift, Lt, LtE, Mod, mod,
Module, Mult, Name, Not, NotEq, NotIn, Num, operator, Or, Param, Pass, Pow,
Print, Raise, Repr, Return, RShift, Set, SetComp, Slice, slice, stmt,
Store, Str, Sub, Subscript, Suite, TryExcept, TryFinally, Tuple, UAdd,
UnaryOp, unaryop, USub, While, With, Yield
)
__version__ = ... # type: str
PyCF_ONLY_AST = ... # type: int
def parse(source: Union[str, bytes], filename: Union[str, bytes] = ..., mode: str = ...) -> AST: ...
def copy_location(new_node: AST, old_node: AST) -> AST: ...
def dump(node: AST, annotate_fields: bool = ..., include_attributes: bool = ...) -> str: ...
def fix_missing_locations(node: AST) -> AST: ...
def get_docstring(node: AST, clean: bool = ...) -> str: ...
def increment_lineno(node: AST, n: int = ...) -> AST: ...
def iter_child_nodes(node: AST) -> Iterator[AST]: ...
def iter_fields(node: AST) -> Iterator[typing.Tuple[str, Any]]: ...
def literal_eval(node_or_string: Union[str, AST]) -> Any: ...
def walk(node: AST) -> Iterator[AST]: ...
class NodeVisitor():
__doc__ = ... # type: str
def visit(self, node: AST) -> Any: ...
def generic_visit(self, node: AST) -> None: ...
class NodeTransformer(NodeVisitor):
__doc__ = ... # type: str
def generic_visit(self, node: AST) -> None: ...

5
stdlib/2/atexit.pyi Normal file
View File

@@ -0,0 +1,5 @@
from typing import TypeVar, Any
_FT = TypeVar('_FT')
def register(func: _FT, *args: Any, **kargs: Any) -> _FT: ...

25
stdlib/2/base64.pyi Normal file
View File

@@ -0,0 +1,25 @@
# Stubs for base64
# Based on http://docs.python.org/3.2/library/base64.html
from typing import IO
def b64encode(s: str, altchars: str = ...) -> str: ...
def b64decode(s: str, altchars: str = ...,
validate: bool = ...) -> str: ...
def standard_b64encode(s: str) -> str: ...
def standard_b64decode(s: str) -> str: ...
def urlsafe_b64encode(s: str) -> str: ...
def urlsafe_b64decode(s: str) -> str: ...
def b32encode(s: str) -> str: ...
def b32decode(s: str, casefold: bool = ...,
map01: str = ...) -> str: ...
def b16encode(s: str) -> str: ...
def b16decode(s: str, casefold: bool = ...) -> str: ...
def decode(input: IO[str], output: IO[str]) -> None: ...
def decodebytes(s: str) -> str: ...
def decodestring(s: str) -> str: ...
def encode(input: IO[str], output: IO[str]) -> None: ...
def encodebytes(s: str) -> str: ...
def encodestring(s: str) -> str: ...

21
stdlib/2/binascii.pyi Normal file
View File

@@ -0,0 +1,21 @@
"""Stubs for the binascii module."""
def a2b_base64(string: str) -> str: ...
def a2b_hex(hexstr: str) -> str: ...
def a2b_hqx(string: str) -> str: ...
def a2b_qp(string: str, header: bool = ...) -> str: ...
def a2b_uu(string: str) -> str: ...
def b2a_base64(data: str) -> str: ...
def b2a_hex(data: str) -> str: ...
def b2a_hqx(data: str) -> str: ...
def b2a_qp(data: str, quotetabs: bool = ..., istext: bool = ..., header: bool = ...) -> str: ...
def b2a_uu(data: str) -> str: ...
def crc32(data: str, crc: int = None) -> int: ...
def crc_hqx(data: str, oldcrc: int) -> int: ...
def hexlify(data: str) -> str: ...
def rlecode_hqx(data: str) -> str: ...
def rledecode_hqx(data: str) -> str: ...
def unhexlify(hexstr: str) -> str: ...
class Error(Exception): ...
class Incomplete(Exception): ...

1
stdlib/2/builtins.pyi Symbolic link
View File

@@ -0,0 +1 @@
__builtin__.pyi

32
stdlib/2/cPickle.pyi Normal file
View File

@@ -0,0 +1,32 @@
from typing import Any, IO, List
HIGHEST_PROTOCOL = ... # type: int
compatible_formats = ... # type: List[str]
format_version = ... # type: str
class Pickler:
def __init__(self, file: IO[str], protocol: int = ...) -> None: ...
def dump(self, obj: Any) -> None: ...
def clear_memo(self) -> None: ...
class Unpickler:
def __init__(self, file: IO[str]) -> None: ...
def load(self) -> Any: ...
def noload(self) -> Any: ...
def dump(obj: Any, file: IO[str], protocol: int = ...) -> None: ...
def dumps(obj: Any, protocol: int = ...) -> str: ...
def load(file: IO[str]) -> Any: ...
def loads(str: str) -> Any: ...
class PickleError(Exception): ...
class UnpicklingError(PickleError): ...
class BadPickleGet(UnpicklingError): ...
class PicklingError(PickleError): ...
class UnpickleableError(PicklingError): ...

50
stdlib/2/cStringIO.pyi Normal file
View File

@@ -0,0 +1,50 @@
# Stubs for cStringIO (Python 2.7)
# See https://docs.python.org/2/library/stringio.html
from typing import overload, IO, List, Iterable, Iterator, Optional, Union
from types import TracebackType
# TODO the typing.IO[] generics should be split into input and output.
class InputType(IO[str], Iterator[str]):
def getvalue(self) -> str: ...
def close(self) -> None: ...
@property
def closed(self) -> bool: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def read(self, size: int = ...) -> str: ...
def readline(self, size: int = ...) -> str: ...
def readlines(self, hint: int = ...) -> List[str]: ...
def seek(self, offset: int, whence: int = ...) -> None: ...
def tell(self) -> int: ...
def truncate(self, size: int = ...) -> Optional[int]: ...
def __iter__(self) -> 'InputType': ...
def next(self) -> str: ...
def reset(self) -> None: ...
class OutputType(IO[str], Iterator[str]):
@property
def softspace(self) -> int: ...
def getvalue(self) -> str: ...
def close(self) -> None: ...
@property
def closed(self) -> bool: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def read(self, size: int = ...) -> str: ...
def readline(self, size: int = ...) -> str: ...
def readlines(self, hint: int = ...) -> List[str]: ...
def seek(self, offset: int, whence: int = ...) -> None: ...
def tell(self) -> int: ...
def truncate(self, size: int = ...) -> Optional[int]: ...
def __iter__(self) -> 'OutputType': ...
def next(self) -> str: ...
def reset(self) -> None: ...
def write(self, b: Union[str, unicode]) -> None: ...
def writelines(self, lines: Iterable[Union[str, unicode]]) -> None: ...
@overload
def StringIO() -> OutputType: ...
@overload
def StringIO(s: str) -> InputType: ...

86
stdlib/2/calendar.pyi Normal file
View File

@@ -0,0 +1,86 @@
from typing import Any, Iterable, Optional, Tuple
import datetime
LocaleType = Tuple[Optional[str], Optional[str]]
class IllegalMonthError(ValueError):
def __init__(self, month: int) -> None: ...
def __str__(self) -> str: ...
class IllegalWeekdayError(ValueError):
def __init__(self, weekday: int) -> None: ...
def __str__(self) -> str: ...
def isleap(year: int) -> bool: ...
def leapdays(y1: int, y2: int) -> int: ...
def weekday(year: int, month: int, day: int) -> int: ...
def monthrange(year: int, month: int) -> Tuple[int, int]: ...
class Calendar(object):
def __init__(self, firstweekday: int = 0) -> None: ...
def getfirstweekday(self) -> int: ...
def setfirstweekday(self, firstweekday: int) -> None: ...
def iterweekdays(self) -> Iterable[int]: ...
def itermonthdates(self, year: int, month: int) -> Iterable[datetime.date]: ...
def itermonthdays2(self, year: int, month: int) -> Iterable[Tuple[int, int]]: ...
def itermonthdays(self, year: int, month: int) -> Iterable[int]: ...
def monthdatescalendar(self, year: int, month: int) -> List[List[datetime.date]]: ...
def monthdays2calendar(self, year: int, month: int) -> List[List[Tuple[int, int]]]: ...
def monthdayscalendar(self, year: int, month: int) -> List[List[int]]: ...
def yeardatescalendar(self, year: int, width: int = 3) -> List[List[int]]: ...
def yeardays2calendar(self, year: int, width: int = 3) -> List[List[Tuple[int, int]]]: ...
def yeardayscalendar(self, year: int, width: int = 3) -> List[List[int]]: ...
class TextCalendar(Calendar):
def prweek(self, theweek: int, width: int) -> None: ...
def formatday(self, day: int, weekday: int, width: int) -> str: ...
def formatweek(self, theweek: int, width: int) -> str: ...
def formatweekday(self, day: int, width: int) -> str: ...
def formatweekheader(self, width: int) -> str: ...
def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ...
def prmonth(self, theyear: int, themonth: int, w: Any=0, l: Any = 0) -> None: ...
def formatmonth(self, theyear: int, themonth: int, w: int = 0, l: int = 0) -> str: ...
def formatyear(self, theyear: int, w: int = 2, l: int = 1, c: int = 6, m: int = 3) -> str: ...
def pryear(self, theyear: int, w: Any = 0, l: Any = 0, c: Any = 6, m: Any = 3) -> None: ...
class HTMLCalendar(Calendar):
def formatday(self, day: int, weekday: int) -> str: ...
def formatweek(self, theweek: int) -> str: ...
def formatweekday(self, day: int) -> str: ...
def formatweekheader(self) -> str: ...
def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
def formatmonth(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
def formatyear(self, theyear: int, width: int = 3) -> str: ...
def formatyearpage(self, theyear: int, width: int = 3, css: Optional[str] = ..., encoding: Optional[str] = ...) -> str: ...
class TimeEncoding:
def __init__(self, locale: LocaleType) -> None: ...
def __enter__(self) -> LocaleType: ...
def __exit__(self, *args) -> None: ...
class LocaleTextCalendar(TextCalendar):
def __init__(self, firstweekday: int = 0, locale: Optional[LocaleType] = ...) -> None: ...
def formatweekday(self, day: int, width: int) -> str: ...
def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ...
class LocaleHTMLCalendar(HTMLCalendar):
def __init__(self, firstweekday: int = 0, locale: Optional[LocaleType] = ...) -> None: ...
def formatweekday(self, day: int) -> str: ...
def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
c = ... # type: TextCalendar
def setfirstweekday(firstweekday: int) -> None: ...
def format(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ...
def formatstring(cols: int, colwidth: int = ..., spacing: int = ...) -> str: ...
def timegm(tuple: Tuple[int, ...]) -> int: ...
# Below constants are not in docs or __all__, but enough people have used them
# they are now effectively public.
MONDAY = ... # type: int
TUESDAY = ... # type: int
WEDNESDAY = ... # type: int
THURSDAY = ... # type: int
FRIDAY = ... # type: int
SATURDAY = ... # type: int
SUNDAY = ... # type: int

202
stdlib/2/codecs.pyi Normal file
View File

@@ -0,0 +1,202 @@
# 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 abc import abstractmethod
# 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 = ..., errors: str = ...) -> _encoded:
...
def decode(obj: _encoded, encoding: str = ..., errors: str = ...) -> _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 = ..., streamwriter: _stream_writer_type = ..., incrementalencoder: _incremental_encoder_type = ..., incrementaldecoder: _incremental_decode_type = ..., name: str = ...) -> None: ...
encode = ... # type: _encode_type
decode = ... # type: _decode_type
streamreader = ... # type: _stream_reader_type
streamwriter = ... # type: _stream_writer_type
incrementalencoder = ... # type: _incremental_encoder_type
incrementaldecoder = ... # type: _incremental_decode_type
name = ... # type: str
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 = ..., encoding: str = ..., errors: str = ..., buffering: int = ...) -> StreamReaderWriter:
...
def EncodedFile(file: BinaryIO, data_encoding: str, file_encoding: str = ..., errors = ...) -> 'StreamRecoder':
...
def iterencode(iterator: Iterable[_decoded], encoding: str, errors: str = ...) -> Iterator[_encoded]:
...
def iterdecode(iterator: Iterable[_encoded], encoding: str, errors: str = ...) -> 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:
# These are sort of @abstractmethod but sort of not.
# The StreamReader and StreamWriter subclasses only implement one.
def encode(self, input: _decoded, errors: str = ...) -> Tuple[_encoded, int]:
...
def decode(self, input: _encoded, errors: str = ...) -> Tuple[_decoded, int]:
...
class IncrementalEncoder:
errors = ... # type: str
def __init__(self, errors: str = ...) -> None:
...
@abstractmethod
def encode(self, object: _decoded, final: bool = ...) -> _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: str
def __init__(self, errors: str = ...) -> None:
...
@abstractmethod
def decode(self, object: _encoded, final: bool = ...) -> _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):
buffer = ... # type: str
def __init__(self, errors: str = ...) -> None:
...
@abstractmethod
def _buffer_encode(self, input: _decoded, errors: str, final: bool) -> _encoded:
...
def encode(self, input: _decoded, final: bool = ...) -> _encoded:
...
class BufferedIncrementalDecoder(IncrementalDecoder):
buffer = ... # type: str
def __init__(self, errors: str = ...) -> None:
...
@abstractmethod
def _buffer_decode(self, input: _encoded, errors: str, final: bool) -> Tuple[_decoded, int]:
...
def decode(self, object: _encoded, final: bool = ...) -> _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):
errors = ... # type: str
def __init__(self, stream: BinaryIO, errors: str = ...) -> None:
...
def write(self, obj: _decoded) -> None:
...
def writelines(self, list: List[str]) -> None:
...
def reset(self) -> None:
...
class StreamReader(Codec):
errors = ... # type: str
def __init__(self, stream: BinaryIO, errors: str = ...) -> None:
...
def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> _decoded:
...
def readline(self, size: int = ..., keepends: bool = ...) -> _decoded:
...
def readlines(self, sizehint: int = ..., keepends: bool = ...) -> List[_decoded]:
...
def reset(self) -> None:
...
class StreamReaderWriter:
def __init__(self, stream: BinaryIO, Reader: _stream_reader_type, Writer: _stream_writer_type, errors: str = ...) -> None:
...
def __enter__(self) -> BinaryIO:
...
def __exit__(self, typ, exc, tb) -> bool:
...
class StreamRecoder(BinaryIO):
def __init__(self, stream: BinaryIO, encode: _encode_type, decode: _decode_type, Reader: _stream_reader_type, Writer: _stream_writer_type, errors: str = ...) -> None:
...

108
stdlib/2/collections.pyi Normal file
View File

@@ -0,0 +1,108 @@
# Stubs for collections
# Based on http://docs.python.org/2.7/library/collections.html
# TODO more abstract base classes (interfaces in mypy)
# NOTE: These are incomplete!
from typing import (
Any, Dict, Generic, TypeVar, Iterable, Tuple, Callable, Mapping, overload, Iterator, Type,
Sized, Optional, List, Set, Sequence, Union, Reversible, MutableMapping, MutableSequence,
Container
)
import typing
_T = TypeVar('_T')
_KT = TypeVar('_KT')
_VT = TypeVar('_VT')
# namedtuple is special-cased in the type checker; the initializer is ignored.
def namedtuple(typename: str, field_names: Union[str, Iterable[Any]], *,
verbose: bool = ..., rename: bool = ...) -> Type[tuple]: ...
class deque(Sized, Iterable[_T], Reversible[_T], Generic[_T]):
def __init__(self, iterable: Iterable[_T] = ...,
maxlen: int = ...) -> None: ...
@property
def maxlen(self) -> Optional[int]: ...
def append(self, x: _T) -> None: ...
def appendleft(self, x: _T) -> None: ...
def clear(self) -> None: ...
def count(self, x: _T) -> int: ...
def extend(self, iterable: Iterable[_T]) -> None: ...
def extendleft(self, iterable: Iterable[_T]) -> None: ...
def pop(self) -> _T: ...
def popleft(self) -> _T: ...
def remove(self, value: _T) -> None: ...
def reverse(self) -> None: ...
def rotate(self, n: int) -> None: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
def __str__(self) -> str: ...
def __hash__(self) -> int: ...
def __getitem__(self, i: int) -> _T: ...
def __setitem__(self, i: int, x: _T) -> None: ...
def __contains__(self, o: _T) -> bool: ...
def __reversed__(self) -> Iterator[_T]: ...
class Counter(Dict[_T, int], Generic[_T]):
# TODO: __init__ keyword arguments
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, Mapping: Mapping[_T, int]) -> None: ...
@overload
def __init__(self, iterable: Iterable[_T]) -> None: ...
def elements(self) -> Iterator[_T]: ...
def most_common(self, n: int = ...) -> List[_T]: ...
@overload
def subtract(self, mapping: Mapping[_T, int]) -> None: ...
@overload
def subtract(self, iterable: Iterable[_T]) -> None: ...
# The Iterable[Tuple[...]] argument type is not actually desirable
# (the tuples will be added as keys, breaking type safety) but
# it's included so that the signature is compatible with
# Dict.update. Not sure if we should use '# type: ignore' instead
# and omit the type from the union.
@overload
def update(self, m: Mapping[_T, int], **kwargs: _VT) -> None: ...
@overload
def update(self, m: Union[Iterable[_T], Iterable[Tuple[_T, int]]], **kwargs: _VT) -> None: ...
class OrderedDict(Dict[_KT, _VT], Generic[_KT, _VT]):
def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ...
def move_to_end(self, key: _KT, last: bool = ...) -> None: ...
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
default_factory = ... # type: Callable[[], _VT]
# TODO: __init__ keyword args
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, map: Mapping[_KT, _VT]) -> None: ...
@overload
def __init__(self, iterable: Iterable[Tuple[_KT, _VT]]) -> None: ...
@overload
def __init__(self, default_factory: Callable[[], _VT]) -> None: ...
@overload
def __init__(self, default_factory: Callable[[], _VT],
map: Mapping[_KT, _VT]) -> None: ...
@overload
def __init__(self, default_factory: Callable[[], _VT],
iterable: Iterable[Tuple[_KT, _VT]]) -> None: ...
def __missing__(self, key: _KT) -> _VT: ...
class ChainMap(Dict[_KT, _VT], Generic[_KT, _VT]):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, *maps: Mapping[_KT, _VT]) -> None: ...
@property
def maps(self) -> List[Mapping[_KT, _VT]]: ...
def new_child(self, m: Mapping[_KT, _VT] = ...) -> ChainMap[_KT, _VT]: ...
@property
def parents(self) -> ChainMap[_KT, _VT]: ...

7
stdlib/2/compileall.pyi Normal file
View File

@@ -0,0 +1,7 @@
# Stubs for compileall (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
def compile_dir(dir, maxlevels=..., ddir=..., force=..., rx=..., quiet=...): ...
def compile_file(fullname, ddir=..., force=..., rx=..., quiet=...): ...
def compile_path(skip_curdir=..., maxlevels=..., force=..., quiet=...): ...

10
stdlib/2/copy.pyi Normal file
View File

@@ -0,0 +1,10 @@
# Stubs for copy
# NOTE: These are incomplete!
from typing import TypeVar, Dict, Any
_T = TypeVar('_T')
def deepcopy(x: _T, memo: Dict[Any, Any] = ...) -> _T: ...
def copy(x: _T) -> _T: ...

88
stdlib/2/csv.pyi Normal file
View File

@@ -0,0 +1,88 @@
# Stubs for csv (Python 2.7)
#
# NOTE: Based on a dynamically typed stub automatically generated by stubgen.
from typing import Any, Dict, Iterable, List, Sequence, Union
# Public interface of _csv.reader's return type
class _Reader(Iterable[List[str]]):
dialect = ... # type: Dialect
line_num = ... # type: int
def next(self) -> List[str]: ...
_Row = Sequence[Union[str, int]]
# Public interface of _csv.writer's return type
class _Writer:
dialect = ... # type: Dialect
def writerow(self, row: _Row) -> None: ...
def writerows(self, rows: Iterable[_Row]) -> None: ...
QUOTE_ALL = ... # type: int
QUOTE_MINIMAL = ... # type: int
QUOTE_NONE = ... # type: int
QUOTE_NONNUMERIC = ... # type: int
class Error(Exception): ...
_Dialect = Union[str, Dialect]
def writer(csvfile: Any, dialect: _Dialect = ..., **fmtparams) -> _Writer: ...
def reader(csvfile: Iterable[str], dialect: _Dialect = ..., **fmtparams) -> _Reader: ...
def register_dialect(name, dialect=..., **fmtparams): ...
def unregister_dialect(name): ...
def get_dialect(name: str) -> Dialect: ...
def list_dialects(): ...
def field_size_limit(new_limit: int = ...) -> int: ...
class Dialect:
delimiter = ... # type: str
quotechar = ... # type: str
escapechar = ... # type: str
doublequote = ... # type: bool
skipinitialspace = ... # type: bool
lineterminator = ... # type: str
quoting = ... # type: int
def __init__(self) -> None: ...
class excel(Dialect):
pass
class excel_tab(excel):
pass
class unix_dialect(Dialect):
pass
class DictReader(Iterable):
restkey = ... # type: Any
restval = ... # type: Any
reader = ... # type: Any
dialect = ... # type: _Dialect
line_num = ... # type: int
fieldnames = ... # type: Sequence[Any]
def __init__(self, f: Iterable[str], fieldnames: Sequence[Any] = ..., restkey=...,
restval=..., dialect: _Dialect = ..., *args, **kwds) -> None: ...
def __iter__(self): ...
def __next__(self): ...
_DictRow = Dict[Any, Union[str, int]]
class DictWriter:
fieldnames = ... # type: Any
restval = ... # type: Any
extrasaction = ... # type: Any
writer = ... # type: Any
def __init__(self, f: Any, fieldnames: Sequence[Any], restval=..., extrasaction: str = ...,
dialect: _Dialect = ..., *args, **kwds) -> None: ...
def writeheader(self) -> None: ...
def writerow(self, rowdict: _DictRow) -> None: ...
def writerows(self, rowdicts: Iterable[_DictRow]) -> None: ...
class Sniffer:
preferred = ... # type: Any
def __init__(self) -> None: ...
def sniff(self, sample: str, delimiters: str = ...) -> Dialect: ...
def has_header(self, sample: str) -> bool: ...

212
stdlib/2/datetime.pyi Normal file
View File

@@ -0,0 +1,212 @@
# Stubs for datetime
# NOTE: These are incomplete!
from time import struct_time
from typing import Optional, SupportsAbs, Tuple, Union, overload
MINYEAR = 0
MAXYEAR = 0
class tzinfo(object):
def tzname(self, dt: Optional[datetime]) -> str: ...
def utcoffset(self, dt: Optional[datetime]) -> Optional[timedelta]: ...
def dst(self, dt: Optional[datetime]) -> Optional[timedelta]: ...
def fromutc(self, dt: datetime) -> datetime: ...
_tzinfo = tzinfo
class date(object):
min = ... # type: date
max = ... # type: date
resolution = ... # type: timedelta
def __init__(self, year: int, month: int = ..., day: int = ...) -> None: ...
@classmethod
def fromtimestamp(cls, t: float) -> date: ...
@classmethod
def today(cls) -> date: ...
@classmethod
def fromordinal(cls, n: int) -> date: ...
@property
def year(self) -> int: ...
@property
def month(self) -> int: ...
@property
def day(self) -> int: ...
def ctime(self) -> str: ...
def strftime(self, fmt: str) -> str: ...
def __format__(self, fmt: Union[str, unicode]) -> str: ...
def isoformat(self) -> str: ...
def timetuple(self) -> struct_time: ...
def toordinal(self) -> int: ...
def replace(self, year: int = ..., month: int = ..., day: int = ...) -> date: ...
def __le__(self, other: date) -> bool: ...
def __lt__(self, other: date) -> bool: ...
def __ge__(self, other: date) -> bool: ...
def __gt__(self, other: date) -> bool: ...
def __add__(self, other: timedelta) -> date: ...
@overload
def __sub__(self, other: timedelta) -> date: ...
@overload
def __sub__(self, other: date) -> timedelta: ...
def __hash__(self) -> int: ...
def weekday(self) -> int: ...
def isoweekday(self) -> int: ...
def isocalendar(self) -> Tuple[int, int, int]: ...
class time:
min = ... # type: time
max = ... # type: time
resolution = ... # type: timedelta
def __init__(self, hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ...,
tzinfo: tzinfo = ...) -> None: ...
@property
def hour(self) -> int: ...
@property
def minute(self) -> int: ...
@property
def second(self) -> int: ...
@property
def microsecond(self) -> int: ...
@property
def tzinfo(self) -> _tzinfo: ...
def __le__(self, other: time) -> bool: ...
def __lt__(self, other: time) -> bool: ...
def __ge__(self, other: time) -> bool: ...
def __gt__(self, other: time) -> bool: ...
def __hash__(self) -> int: ...
def isoformat(self) -> str: ...
def strftime(self, fmt: str) -> str: ...
def __format__(self, fmt: str) -> str: ...
def utcoffset(self) -> Optional[timedelta]: ...
def tzname(self) -> Optional[str]: ...
def dst(self) -> Optional[int]: ...
def replace(self, hour: int = ..., minute: int = ..., second: int = ...,
microsecond: int = ..., tzinfo: Union[_tzinfo, bool] = ...) -> time: ...
_date = date
_time = time
class timedelta(SupportsAbs[timedelta]):
min = ... # type: timedelta
max = ... # type: timedelta
resolution = ... # type: timedelta
def __init__(self, days: float = ..., seconds: float = ..., microseconds: float = ...,
milliseconds: float = ..., minutes: float = ..., hours: float = ...,
weeks: float = ...) -> None: ...
@property
def days(self) -> int: ...
@property
def seconds(self) -> int: ...
@property
def microseconds(self) -> int: ...
def total_seconds(self) -> float: ...
def __add__(self, other: timedelta) -> timedelta: ...
def __radd__(self, other: timedelta) -> timedelta: ...
def __sub__(self, other: timedelta) -> timedelta: ...
def __rsub(self, other: timedelta) -> timedelta: ...
def __neg__(self) -> timedelta: ...
def __pos__(self) -> timedelta: ...
def __abs__(self) -> timedelta: ...
def __mul__(self, other: float) -> timedelta: ...
def __rmul__(self, other: float) -> timedelta: ...
@overload
def __floordiv__(self, other: timedelta) -> int: ...
@overload
def __floordiv__(self, other: int) -> timedelta: ...
@overload
def __truediv__(self, other: timedelta) -> float: ...
@overload
def __truediv__(self, other: float) -> timedelta: ...
def __mod__(self, other: timedelta) -> timedelta: ...
def __divmod__(self, other: timedelta) -> Tuple[int, timedelta]: ...
def __le__(self, other: timedelta) -> bool: ...
def __lt__(self, other: timedelta) -> bool: ...
def __ge__(self, other: timedelta) -> bool: ...
def __gt__(self, other: timedelta) -> bool: ...
def __hash__(self) -> int: ...
class datetime(object):
# TODO: is actually subclass of date, but __le__, __lt__, __ge__, __gt__ don't work with date.
min = ... # type: datetime
max = ... # type: datetime
resolution = ... # type: timedelta
def __init__(self, year: int, month: int = ..., day: int = ..., hour: int = ...,
minute: int = ..., second: int = ..., microseconds: int = ...,
tzinfo: tzinfo = ...) -> None: ...
@property
def year(self) -> int: ...
@property
def month(self) -> int: ...
@property
def day(self) -> int: ...
@property
def hour(self) -> int: ...
@property
def minute(self) -> int: ...
@property
def second(self) -> int: ...
@property
def microsecond(self) -> int: ...
@property
def tzinfo(self) -> _tzinfo: ...
@classmethod
def fromtimestamp(cls, t: float, tz: _tzinfo = ...) -> datetime: ...
@classmethod
def utcfromtimestamp(cls, t: float) -> datetime: ...
@classmethod
def today(cls) -> datetime: ...
@classmethod
def fromordinal(cls, n: int) -> datetime: ...
@classmethod
def now(cls, tz: _tzinfo = ...) -> datetime: ...
@classmethod
def utcnow(cls) -> datetime: ...
@classmethod
def combine(cls, date: date, time: time) -> datetime: ...
def strftime(self, fmt: str) -> str: ...
def __format__(self, fmt: str) -> str: ...
def toordinal(self) -> int: ...
def timetuple(self) -> struct_time: ...
def timestamp(self) -> float: ...
def utctimetuple(self) -> struct_time: ...
def date(self) -> _date: ...
def time(self) -> _time: ...
def timetz(self) -> _time: ...
def replace(self, year: int = ..., month: int = ..., day: int = ..., hour: int = ...,
minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo:
Union[_tzinfo, bool] = ...) -> datetime: ...
def astimezone(self, tz: _tzinfo = ...) -> datetime: ...
def ctime(self) -> str: ...
def isoformat(self, sep: str = ...) -> str: ...
@classmethod
def strptime(cls, date_string: str, format: str) -> datetime: ...
def utcoffset(self) -> Optional[timedelta]: ...
def tzname(self) -> Optional[str]: ...
def dst(self) -> Optional[int]: ...
def __le__(self, other: datetime) -> bool: ...
def __lt__(self, other: datetime) -> bool: ...
def __ge__(self, other: datetime) -> bool: ...
def __gt__(self, other: datetime) -> bool: ...
def __add__(self, other: timedelta) -> datetime: ...
@overload
def __sub__(self, other: datetime) -> timedelta: ...
@overload
def __sub__(self, other: timedelta) -> datetime: ...
def __hash__(self) -> int: ...
def weekday(self) -> int: ...
def isoweekday(self) -> int: ...
def isocalendar(self) -> Tuple[int, int, int]: ...

245
stdlib/2/decimal.pyi Normal file
View File

@@ -0,0 +1,245 @@
# Stubs for decimal (Python 2)
from typing import (
Any, Dict, NamedTuple, Optional, Sequence, Tuple, Union,
SupportsAbs, SupportsFloat, SupportsInt,
)
_Decimal = Union[Decimal, int]
_ComparableNum = Union[Decimal, int, float]
DecimalTuple = NamedTuple('DecimalTuple',
[('sign', int),
('digits', Sequence[int]), # TODO: Use Tuple[int, ...]
('exponent', int)])
ROUND_DOWN = ... # type: str
ROUND_HALF_UP = ... # type: str
ROUND_HALF_EVEN = ... # type: str
ROUND_CEILING = ... # type: str
ROUND_FLOOR = ... # type: str
ROUND_UP = ... # type: str
ROUND_HALF_DOWN = ... # type: str
ROUND_05UP = ... # type: str
class DecimalException(ArithmeticError):
def handle(self, context, *args): ...
class Clamped(DecimalException): ...
class InvalidOperation(DecimalException): ...
class ConversionSyntax(InvalidOperation): ...
class DivisionByZero(DecimalException, ZeroDivisionError): ...
class DivisionImpossible(InvalidOperation): ...
class DivisionUndefined(InvalidOperation, ZeroDivisionError): ...
class Inexact(DecimalException): ...
class InvalidContext(InvalidOperation): ...
class Rounded(DecimalException): ...
class Subnormal(DecimalException): ...
class Overflow(Inexact, Rounded): ...
class Underflow(Inexact, Rounded, Subnormal): ...
def setcontext(context: Context): ...
def getcontext() -> Context: ...
def localcontext(ctx: Optional[Context] = None) -> _ContextManager: ...
class Decimal(SupportsAbs[Decimal], SupportsFloat, SupportsInt):
def __init__(cls, value: Union[_Decimal, float, str,
Tuple[int, Sequence[int], int]] = ...,
context: Context = ...) -> None: ...
@classmethod
def from_float(cls, f: float) -> Decimal: ...
def __nonzero__(self) -> bool: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def __lt__(self, other: _ComparableNum) -> bool: ...
def __le__(self, other: _ComparableNum) -> bool: ...
def __gt__(self, other: _ComparableNum) -> bool: ...
def __ge__(self, other: _ComparableNum) -> bool: ...
def compare(self, other: _Decimal) -> Decimal: ...
def __hash__(self) -> int: ...
def as_tuple(self) -> DecimalTuple: ...
def to_eng_string(self, context: Context = ...) -> str: ...
def __neg__(self) -> Decimal: ...
def __pos__(self) -> Decimal: ...
def __abs__(self, round: bool = True) -> Decimal: ...
def __add__(self, other: _Decimal) -> Decimal: ...
def __radd__(self, other: int) -> Decimal: ...
def __sub__(self, other: _Decimal) -> Decimal: ...
def __rsub__(self, other: int) -> Decimal: ...
def __mul__(self, other: _Decimal) -> Decimal: ...
def __rmul__(self, other: int) -> Decimal: ...
def __truediv__(self, other: _Decimal) -> Decimal: ...
def __rtruediv__(self, other: int) -> Decimal: ...
def __div__(self, other: _Decimal) -> Decimal: ...
def __rdiv__(self, other: int) -> Decimal: ...
def __divmod__(self, other: _Decimal) -> Tuple[Decimal, Decimal]: ...
def __rdivmod__(self, other: int) -> Tuple[Decimal, Decimal]: ...
def __mod__(self, other: _Decimal) -> Decimal: ...
def __rmod__(self, other: int) -> Decimal: ...
def remainder_near(self, other: _Decimal, context: Context = ...) -> Decimal: ...
def __floordiv__(self, other: _Decimal) -> Decimal: ...
def __rfloordiv__(self, other: int) -> Decimal: ...
def __float__(self) -> float: ...
def __int__(self) -> int: ...
def __trunc__(self) -> int: ...
@property
def imag(self) -> Decimal: ...
@property
def real(self) -> Decimal: ...
def conjugate(self) -> Decimal: ...
def __complex__(self) -> complex: ...
def __long__(self) -> long: ...
def fma(self, other: _Decimal, third: _Decimal, context: Context = ...) -> Decimal: ...
def __pow__(self, other: _Decimal) -> Decimal: ...
def __rpow__(self, other: int) -> Decimal: ...
def normalize(self, context: Context = ...) -> Decimal: ...
def quantize(self, exp: _Decimal, rounding: str = ...,
context: Context = ...) -> Decimal: ...
def same_quantum(self, other: Decimal) -> bool: ...
def to_integral(self, rounding: str = ..., context: Context = ...) -> Decimal: ...
def to_integral_exact(self, rounding: str = ..., context: Context = ...) -> Decimal: ...
def to_integral_value(self, rounding: str = ..., context: Context = ...) -> Decimal: ...
def sqrt(self, context: Context = ...) -> Decimal: ...
def max(self, other: _Decimal, context: Context = ...) -> Decimal: ...
def min(self, other: _Decimal, context: Context = ...) -> Decimal: ...
def adjusted(self) -> int: ...
def canonical(self, context: Context = ...) -> Decimal: ...
def compare_signal(self, other: _Decimal, context: Context = ...) -> Decimal: ...
def compare_total(self, other: _Decimal) -> Decimal: ...
def compare_total_mag(self, other: _Decimal) -> Decimal: ...
def copy_abs(self) -> Decimal: ...
def copy_negate(self) -> Decimal: ...
def copy_sign(self, other: _Decimal) -> Decimal: ...
def exp(self, context: Context = ...) -> Decimal: ...
def is_canonical(self) -> bool: ...
def is_finite(self) -> bool: ...
def is_infinite(self) -> bool: ...
def is_nan(self) -> bool: ...
def is_normal(self, context: Context = ...) -> bool: ...
def is_qnan(self) -> bool: ...
def is_signed(self) -> bool: ...
def is_snan(self) -> bool: ...
def is_subnormal(self, context: Context = ...) -> bool: ...
def is_zero(self) -> bool: ...
def ln(self, context: Context = ...) -> Decimal: ...
def log10(self, context: Context = ...) -> Decimal: ...
def logb(self, context: Context = ...) -> Decimal: ...
def logical_and(self, other: _Decimal, context: Context = ...) -> Decimal: ...
def logical_invert(self, context: Context = ...) -> Decimal: ...
def logical_or(self, other: _Decimal, context: Context = ...) -> Decimal: ...
def logical_xor(self, other: _Decimal, context: Context = ...) -> Decimal: ...
def max_mag(self, other: _Decimal, context: Context = ...) -> Decimal: ...
def min_mag(self, other: _Decimal, context: Context = ...) -> Decimal: ...
def next_minus(self, context: Context = ...) -> Decimal: ...
def next_plus(self, context: Context = ...) -> Decimal: ...
def next_toward(self, other: _Decimal, context: Context = ...) -> Decimal: ...
def number_class(self, context: Context = ...) -> str: ...
def radix(self) -> Decimal: ...
def rotate(self, other: _Decimal, context: Context = ...) -> Decimal: ...
def scaleb(self, other: _Decimal, context: Context = ...) -> Decimal: ...
def shift(self, other: _Decimal, context: Context = ...) -> Decimal: ...
def __reduce__(self): ...
def __copy__(self): ...
def __deepcopy__(self, memo): ...
def __format__(self, specifier, context=None, _localeconv=None) -> str: ...
class _ContextManager:
new_context = ... # type: Context
saved_context = ... # type: Context
def __init__(self, new_context: Context) -> None: ...
def __enter__(self): ...
def __exit__(self, t, v, tb): ...
class Context:
prec = ... # type: int
rounding = ... # type: str
Emin = ... # type: int
Emax = ... # type: int
capitals = ... # type: int
traps = ... # type: Dict[type, bool]
flags = ... # type: Any
def __init__(self, prec=None, rounding=None, traps=None, flags=None, Emin=None, Emax=None, capitals=None, _clamp=0, _ignored_flags=None): ...
def clear_flags(self): ...
def copy(self): ...
__copy__ = ... # type: Any
__hash__ = ... # type: Any
def Etiny(self): ...
def Etop(self): ...
def create_decimal(self, num=...): ...
def create_decimal_from_float(self, f): ...
def abs(self, a): ...
def add(self, a, b): ...
def canonical(self, a): ...
def compare(self, a, b): ...
def compare_signal(self, a, b): ...
def compare_total(self, a, b): ...
def compare_total_mag(self, a, b): ...
def copy_abs(self, a): ...
def copy_decimal(self, a): ...
def copy_negate(self, a): ...
def copy_sign(self, a, b): ...
def divide(self, a, b): ...
def divide_int(self, a, b): ...
def divmod(self, a, b): ...
def exp(self, a): ...
def fma(self, a, b, c): ...
def is_canonical(self, a): ...
def is_finite(self, a): ...
def is_infinite(self, a): ...
def is_nan(self, a): ...
def is_normal(self, a): ...
def is_qnan(self, a): ...
def is_signed(self, a): ...
def is_snan(self, a): ...
def is_subnormal(self, a): ...
def is_zero(self, a): ...
def ln(self, a): ...
def log10(self, a): ...
def logb(self, a): ...
def logical_and(self, a, b): ...
def logical_invert(self, a): ...
def logical_or(self, a, b): ...
def logical_xor(self, a, b): ...
def max(self, a, b): ...
def max_mag(self, a, b): ...
def min(self, a, b): ...
def min_mag(self, a, b): ...
def minus(self, a): ...
def multiply(self, a, b): ...
def next_minus(self, a): ...
def next_plus(self, a): ...
def next_toward(self, a, b): ...
def normalize(self, a): ...
def number_class(self, a): ...
def plus(self, a): ...
def power(self, a, b, modulo=None): ...
def quantize(self, a, b): ...
def radix(self): ...
def remainder(self, a, b): ...
def remainder_near(self, a, b): ...
def rotate(self, a, b): ...
def same_quantum(self, a, b): ...
def scaleb(self, a, b): ...
def shift(self, a, b): ...
def sqrt(self, a): ...
def subtract(self, a, b): ...
def to_eng_string(self, a): ...
def to_sci_string(self, a): ...
def to_integral_exact(self, a): ...
def to_integral_value(self, a): ...
def to_integral(self, a): ...
DefaultContext = ... # type: Context
BasicContext = ... # type: Context
ExtendedContext = ... # type: Context

64
stdlib/2/difflib.pyi Normal file
View File

@@ -0,0 +1,64 @@
# Stubs for difflib
# Based on https://docs.python.org/2.7/library/difflib.html
# TODO: Support unicode?
from typing import (
TypeVar, Callable, Iterable, Iterator, List, NamedTuple, Sequence, Tuple,
Generic, Optional
)
_T = TypeVar('_T')
class SequenceMatcher(Generic[_T]):
def __init__(self, isjunk: Optional[Callable[[_T], bool]] = ...,
a: Sequence[_T] = ..., b: Sequence[_T] = ...,
autojunk: bool = ...) -> None: ...
def set_seqs(self, a: Sequence[_T], b: Sequence[_T]) -> None: ...
def set_seq1(self, a: Sequence[_T]) -> None: ...
def set_seq2(self, b: Sequence[_T]) -> None: ...
def find_longest_match(self, alo: int, ahi: int, blo: int,
bhi: int) -> Tuple[int, int, int]: ...
def get_matching_blocks(self) -> List[Tuple[int, int, int]]: ...
def get_opcodes(self) -> List[Tuple[str, int, int, int, int]]: ...
def get_grouped_opcodes(self, n: int = ...
) -> Iterable[Tuple[str, int, int, int, int]]: ...
def ratio(self) -> float: ...
def quick_ratio(self) -> float: ...
def real_quick_ratio(self) -> float: ...
def get_close_matches(word: Sequence[_T], possibilities: List[Sequence[_T]],
n: int = ..., cutoff: float = ...) -> List[Sequence[_T]]: ...
class Differ:
def __init__(self, linejunk: Callable[[str], bool] = ...,
charjunk: Callable[[str], bool] = ...) -> None: ...
def compare(self, a: Sequence[str], b: Sequence[str]) -> Iterator[str]: ...
def IS_LINE_JUNK(str) -> bool: ...
def IS_CHARACTER_JUNK(str) -> bool: ...
def unified_diff(a: Sequence[str], b: Sequence[str], fromfile: str = ...,
tofile: str = ..., fromfiledate: str = ..., tofiledate: str = ...,
n: int = ..., lineterm: str = ...) -> Iterator[str]: ...
def context_diff(a: Sequence[str], b: Sequence[str], fromfile: str=...,
tofile: str = ..., fromfiledate: str = ..., tofiledate: str = ...,
n: int = ..., lineterm: str = ...) -> Iterator[str]: ...
def ndiff(a: Sequence[str], b: Sequence[str],
linejunk: Callable[[str], bool] = ...,
charjunk: Callable[[str], bool] = ...
) -> Iterator[str]: ...
class HtmlDiff(object):
def __init__(self, tabsize: int = ..., wrapcolumn: int = ...,
linejunk: Callable[[str], bool] = ...,
charjunk: Callable[[str], bool] = ...
) -> None: ...
def make_file(self, fromlines: Sequence[str], tolines: Sequence[str],
fromdesc: str = ..., todesc: str = ..., context: bool = ...,
numlines: int = ...) -> str: ...
def make_table(self, fromlines: Sequence[str], tolines: Sequence[str],
fromdesc: str = ..., todesc: str = ..., context: bool = ...,
numlines: int = ...) -> str: ...
def restore(delta: Iterable[str], which: int) -> Iterator[int]: ...

View File

View File

@@ -0,0 +1,5 @@
# Stubs for emxccompiler
from distutils.unixccompiler import UnixCCompiler
class EMXCCompiler(UnixCCompiler): ...

9
stdlib/2/doctest.pyi Normal file
View File

@@ -0,0 +1,9 @@
# Stubs for doctest
# NOTE: These are incomplete!
from typing import Any, Tuple
# TODO arguments missing
def testmod(m: Any = ..., name: str = ..., globs: Any = ...,
verbose: bool = ...) -> Tuple[int, int]: ...

View File

@@ -0,0 +1,8 @@
# Stubs for email.MIMEText (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from email.mime.nonmultipart import MIMENonMultipart
class MIMEText(MIMENonMultipart):
def __init__(self, _text, _subtype=..., _charset=...) -> None: ...

View File

@@ -0,0 +1,6 @@
from typing import IO, Any, AnyStr
def message_from_string(s: AnyStr, *args, **kwargs): ...
def message_from_bytes(s: str, *args, **kwargs): ...
def message_from_file(fp: IO[AnyStr], *args, **kwargs): ...
def message_from_binary_file(fp: IO[str], *args, **kwargs): ...

View File

@@ -0,0 +1,44 @@
# Stubs for email._parseaddr (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from typing import Any
def parsedate_tz(data): ...
def parsedate(data): ...
def mktime_tz(data): ...
def quote(str): ...
class AddrlistClass:
specials = ... # type: Any
pos = ... # type: Any
LWS = ... # type: Any
CR = ... # type: Any
FWS = ... # type: Any
atomends = ... # type: Any
phraseends = ... # type: Any
field = ... # type: Any
commentlist = ... # type: Any
def __init__(self, field): ...
def gotonext(self): ...
def getaddrlist(self): ...
def getaddress(self): ...
def getrouteaddr(self): ...
def getaddrspec(self): ...
def getdomain(self): ...
def getdelimited(self, beginchar, endchars, allowcomments=True): ...
def getquote(self): ...
def getcomment(self): ...
def getdomainliteral(self): ...
def getatom(self, atomends=None): ...
def getphraselist(self): ...
class AddressList(AddrlistClass):
addresslist = ... # type: Any
def __init__(self, field): ...
def __len__(self): ...
def __add__(self, other): ...
def __iadd__(self, other): ...
def __sub__(self, other): ...
def __isub__(self, other): ...
def __getitem__(self, index): ...

View File

View File

@@ -0,0 +1,10 @@
# Stubs for email.mime.base (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
# import message
# TODO
#class MIMEBase(message.Message):
class MIMEBase:
def __init__(self, _maintype, _subtype, **_params) -> None: ...

View File

@@ -0,0 +1,8 @@
# Stubs for email.mime.multipart (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from email.mime.base import MIMEBase
class MIMEMultipart(MIMEBase):
def __init__(self, _subtype=..., boundary=..., _subparts=..., **_params) -> None: ...

View File

@@ -0,0 +1,8 @@
# Stubs for email.mime.nonmultipart (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from email.mime.base import MIMEBase
class MIMENonMultipart(MIMEBase):
def attach(self, payload): ...

View File

@@ -0,0 +1,8 @@
# Stubs for email.mime.text (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from email.mime.nonmultipart import MIMENonMultipart
class MIMEText(MIMENonMultipart):
def __init__(self, _text, _subtype=..., _charset=...) -> None: ...

22
stdlib/2/email/utils.pyi Normal file
View File

@@ -0,0 +1,22 @@
# Stubs for email.utils (Python 2)
#
# Derived from stub automatically generated by stubgen.
from email._parseaddr import AddressList as _AddressList
from email._parseaddr import mktime_tz as mktime_tz
from email._parseaddr import parsedate as _parsedate
from email._parseaddr import parsedate_tz as _parsedate_tz
from quopri import decodestring as _qdecode
def formataddr(pair): ...
def getaddresses(fieldvalues): ...
def formatdate(timeval=None, localtime=False, usegmt=False): ...
def make_msgid(idstring=None): ...
def parsedate(data): ...
def parsedate_tz(data): ...
def parseaddr(addr): ...
def unquote(str): ...
def decode_rfc2231(s): ...
def encode_rfc2231(s, charset=None, language=None): ...
def decode_params(params): ...
def collapse_rfc2231_value(value, errors=..., fallback_charset=...): ...

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 = ...) -> bytes: pass
def decode(input: bytes, errors: str = ...) -> str: pass

80
stdlib/2/exceptions.pyi Normal file
View File

@@ -0,0 +1,80 @@
from typing import Any, List, Optional
class StandardError(Exception): ...
class ArithmeticError(StandardError): ...
class AssertionError(StandardError): ...
class AttributeError(StandardError): ...
class BaseException(object):
args = ... # type: List[Any]
message = ... # type: str
def __getslice__(self, start, end) -> Any: ...
def __getitem__(self, start, end) -> Any: ...
def __unicode__(self) -> unicode: ...
class BufferError(StandardError): ...
class BytesWarning(Warning): ...
class DeprecationWarning(Warning): ...
class EOFError(StandardError): ...
class EnvironmentError(StandardError):
errno = ... # type: int
strerror = ... # type: str
filename = ... # type: str
class Exception(BaseException): ...
class FloatingPointError(ArithmeticError): ...
class FutureWarning(Warning): ...
class GeneratorExit(BaseException): ...
class IOError(EnvironmentError): ...
class ImportError(StandardError): ...
class ImportWarning(Warning): ...
class IndentationError(SyntaxError): ...
class IndexError(LookupError): ...
class KeyError(LookupError): ...
class KeyboardInterrupt(BaseException): ...
class LookupError(StandardError): ...
class MemoryError(StandardError): ...
class NameError(StandardError): ...
class NotImplementedError(RuntimeError): ...
class OSError(EnvironmentError): ...
class OverflowError(ArithmeticError): ...
class PendingDeprecationWarning(Warning): ...
class ReferenceError(StandardError): ...
class RuntimeError(StandardError): ...
class RuntimeWarning(Warning): ...
class StopIteration(Exception): ...
class SyntaxError(StandardError):
text = ... # type: str
print_file_and_line = ... # type: Optional[str]
filename = ... # type: str
lineno = ... # type: int
offset = ... # type: int
msg = ... # type: str
class SyntaxWarning(Warning): ...
class SystemError(StandardError): ...
class SystemExit(BaseException):
code = ... # type: int
class TabError(IndentationError): ...
class TypeError(StandardError): ...
class UnboundLocalError(NameError): ...
class UnicodeError(ValueError): ...
class UnicodeDecodeError(UnicodeError):
start = ... # type: int
reason = ... # type: str
object = ... # type: str
end = ... # type: int
encoding = ... # type: str
class UnicodeEncodeError(UnicodeError):
start = ... # type: int
reason = ... # type: str
object = ... # type: unicode
end = ... # type: int
encoding = ... # type: str
class UnicodeTranslateError(UnicodeError):
start = ... # type: int
reason = ... # type: str
object = ... # type: Any
end = ... # type: int
encoding = ... # type: str
class UnicodeWarning(Warning): ...
class UserWarning(Warning): ...
class ValueError(StandardError): ...
class Warning(Exception): ...
class ZeroDivisionError(ArithmeticError): ...

87
stdlib/2/fcntl.pyi Normal file
View File

@@ -0,0 +1,87 @@
from typing import Any, Union
import io
FASYNC = ... # type: int
FD_CLOEXEC = ... # type: int
DN_ACCESS = ... # type: int
DN_ATTRIB = ... # type: int
DN_CREATE = ... # type: int
DN_DELETE = ... # type: int
DN_MODIFY = ... # type: int
DN_MULTISHOT = ... # type: int
DN_RENAME = ... # type: int
F_DUPFD = ... # type: int
F_EXLCK = ... # type: int
F_GETFD = ... # type: int
F_GETFL = ... # type: int
F_GETLEASE = ... # type: int
F_GETLK = ... # type: int
F_GETLK64 = ... # type: int
F_GETOWN = ... # type: int
F_GETSIG = ... # type: int
F_NOTIFY = ... # type: int
F_RDLCK = ... # type: int
F_SETFD = ... # type: int
F_SETFL = ... # type: int
F_SETLEASE = ... # type: int
F_SETLK = ... # type: int
F_SETLK64 = ... # type: int
F_SETLKW = ... # type: int
F_SETLKW64 = ... # type: int
F_SETOWN = ... # type: int
F_SETSIG = ... # type: int
F_SHLCK = ... # type: int
F_UNLCK = ... # type: int
F_WRLCK = ... # type: int
I_ATMARK = ... # type: int
I_CANPUT = ... # type: int
I_CKBAND = ... # type: int
I_FDINSERT = ... # type: int
I_FIND = ... # type: int
I_FLUSH = ... # type: int
I_FLUSHBAND = ... # type: int
I_GETBAND = ... # type: int
I_GETCLTIME = ... # type: int
I_GETSIG = ... # type: int
I_GRDOPT = ... # type: int
I_GWROPT = ... # type: int
I_LINK = ... # type: int
I_LIST = ... # type: int
I_LOOK = ... # type: int
I_NREAD = ... # type: int
I_PEEK = ... # type: int
I_PLINK = ... # type: int
I_POP = ... # type: int
I_PUNLINK = ... # type: int
I_PUSH = ... # type: int
I_RECVFD = ... # type: int
I_SENDFD = ... # type: int
I_SETCLTIME = ... # type: int
I_SETSIG = ... # type: int
I_SRDOPT = ... # type: int
I_STR = ... # type: int
I_SWROPT = ... # type: int
I_UNLINK = ... # type: int
LOCK_EX = ... # type: int
LOCK_MAND = ... # type: int
LOCK_NB = ... # type: int
LOCK_READ = ... # type: int
LOCK_RW = ... # type: int
LOCK_SH = ... # type: int
LOCK_UN = ... # type: int
LOCK_WRITE = ... # type: int
_ANYFILE = Union[int, io.IOBase]
# TODO All these return either int or bytes depending on the value of
# cmd (not on the type of arg).
def fcntl(fd: _ANYFILE, op: int, arg: Union[int, bytes] = ...) -> Any: ...
# TODO: arg: int or read-only buffer interface or read-write buffer interface
def ioctl(fd: _ANYFILE, op: int, arg: Union[int, bytes] = ...,
mutate_flag: bool = ...) -> Any: ...
def flock(fd: _ANYFILE, op: int) -> None: ...
def lockf(fd: _ANYFILE, op: int, length: int = ..., start: int = ...,
whence: int = ...) -> Any: ...

46
stdlib/2/fileinput.pyi Normal file
View File

@@ -0,0 +1,46 @@
from typing import Iterable, Callable, IO, Optional, Union, Iterator
class FileInput(Iterable[str]):
def __init__(
self,
files: Optional[Union[str, Iterable[str]]] = None,
inplace: bool = ...,
backup: str = ...,
bufsize: int = ...,
mode: str = ...,
openhook: Callable[[str, str], IO[str]] = ...
) -> None: ...
def __del__(self) -> None: ...
def close(self) -> None: ...
def __iter__(self) -> Iterator[str]: ...
def __getitem__(self, i: Union[int, slice]) -> str: ...
def next(self) -> str: ...
def nextfile(self) -> None: ...
def readline(self) -> str: ...
def filename(self) -> Optional[str]: ...
def lineno(self) -> int: ...
def filelineno(self) -> int: ...
def fileno(self) -> int: ...
def isfirstline(self) -> bool: ...
def isstdin(self) -> bool: ...
def input(
files: Optional[Union[str, Iterable[str]]] = None,
inplace: bool = ...,
backup: str = ...,
bufsize: int = ...,
mode: str = ...,
openhook: Callable[[str, str], IO[str]] = ...) -> FileInput: ...
def filename() -> Optional[str]: ...
def lineno() -> int: ...
def filelineno() -> int: ...
def isfirstline() -> bool: ...
def isstdin() -> bool: ...
def nextfile() -> None: ...
def close() -> None: ...
def hook_compressed(filename: str, mode: str) -> IO[str]: ...
def hook_encoded(encoding: str) -> Callable[[str, str], IO[str]]: ...

6
stdlib/2/fnmatch.pyi Normal file
View File

@@ -0,0 +1,6 @@
from typing import Iterable
def fnmatch(filename: str, pattern: str) -> bool: ...
def fnmatchcase(filename: str, pattern: str) -> bool: ...
def filter(names: Iterable[str], pattern: str) -> Iterable[str]: ...
def translate(pattern: str) -> str: ...

34
stdlib/2/functools.pyi Normal file
View File

@@ -0,0 +1,34 @@
# Stubs for functools (Python 2.7)
# NOTE: These are incomplete!
from abc import ABCMeta, abstractmethod
from typing import Any, Callable, Generic, Dict, Iterable, Optional, Sequence, Tuple, TypeVar, overload
from collections import namedtuple
_AnyCallable = Callable[..., Any]
_T = TypeVar("_T")
_S = TypeVar("_S")
@overload
def reduce(function: Callable[[_T, _T], _T],
sequence: Iterable[_T]) -> _T: ...
@overload
def reduce(function: Callable[[_T, _S], _T],
sequence: Iterable[_S], initial: _T) -> _T: ...
WRAPPER_ASSIGNMENTS = ... # type: Sequence[str]
WRAPPER_UPDATES = ... # type: Sequence[str]
def update_wrapper(wrapper: _AnyCallable, wrapped: _AnyCallable, assigned: Sequence[str] = ...,
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: Callable[[_T, _T], int]) -> Callable[[_T], Any]: ...
class partial(Generic[_T]):
func = ... # Callable[..., _T]
args = ... # type: Tuple[Any, ...]
keywords = ... # type: Dict[str, Any]
def __init__(self, func: Callable[..., _T], *args: Any, **kwargs: Any) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> _T: ...

View File

@@ -0,0 +1,14 @@
from typing import Any
from itertools import ifilter as filter
from itertools import imap as map
from itertools import izip as zip
def ascii(obj: Any) -> str: ...
def hex(x: int) -> str: ...
def oct(x: int) -> str: ...

29
stdlib/2/gc.pyi Normal file
View File

@@ -0,0 +1,29 @@
# Stubs for gc
from typing import Any, List, Tuple
def enable() -> None: ...
def disable() -> None: ...
def isenabled() -> bool: ...
def collect(generation: int = ...) -> int: ...
def set_debug(flags: int) -> None: ...
def get_debug() -> int: ...
def get_objects() -> List[Any]: ...
def set_threshold(threshold0: int, threshold1: int = ...,
threshold2: int = ...) -> None: ...
def get_count() -> Tuple[int, int, int]: ...
def get_threshold() -> Tuple[int, int, int]: ...
def get_referrers(*objs: Any) -> List[Any]: ...
def get_referents(*objs: Any) -> List[Any]: ...
def is_tracked(obj: Any) -> bool: ...
garbage = ... # type: List[Any]
DEBUG_STATS = ... # type: int
DEBUG_COLLECTABLE = ... # type: int
DEBUG_UNCOLLECTABLE = ... # type: int
DEBUG_INSTANCES = ... # type: int
DEBUG_OBJECTS = ... # type: int
DEBUG_SAVEALL = ... # type: int
DEBUG_LEAK = ... # type: int

14
stdlib/2/genericpath.pyi Normal file
View File

@@ -0,0 +1,14 @@
# Stubs for genericpath (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
class _unicode: ...
def exists(path): ...
def isfile(path): ...
def isdir(s): ...
def getsize(filename): ...
def getmtime(filename): ...
def getatime(filename): ...
def getctime(filename): ...
def commonprefix(m): ...

17
stdlib/2/getopt.pyi Normal file
View File

@@ -0,0 +1,17 @@
from typing import List, Tuple
class GetoptError(Exception):
opt = ... # type: str
msg = ... # type: str
def __init__(self, msg: str, opt: str=...) -> None: ...
def __str__(self) -> str: ...
error = GetoptError
def getopt(args: List[str], shortopts: str,
longopts: List[str]=...) -> Tuple[List[Tuple[str, str]],
List[str]]: ...
def gnu_getopt(args: List[str], shortopts: str,
longopts: List[str]=...) -> Tuple[List[Tuple[str,str]],
List[str]]: ...

8
stdlib/2/getpass.pyi Normal file
View File

@@ -0,0 +1,8 @@
# Stubs for getpass (Python 2)
from typing import Any, IO
class GetPassWarning(UserWarning): ...
def getpass(prompt: str = ..., stream: IO[Any] = ...) -> str: ...
def getuser() -> str: ...

43
stdlib/2/gettext.pyi Normal file
View File

@@ -0,0 +1,43 @@
# TODO(MichalPokorny): better types
from typing import Any, IO, List, Optional, Union
def bindtextdomain(domain: str, localedir: str = ...) -> str: ...
def bind_textdomain_codeset(domain: str, codeset: str = ...) -> str: ...
def textdomain(domain: str = ...) -> str: ...
def gettext(message: str) -> str: ...
def lgettext(message: str) -> str: ...
def dgettext(domain: str, message: str) -> str: ...
def ldgettext(domain: str, message: str) -> str: ...
def ngettext(singular: str, plural: str, n: int) -> str: ...
def lngettext(singular: str, plural: str, n: int) -> str: ...
def dngettext(domain: str, singular: str, plural: str, n: int) -> str: ...
def ldngettext(domain: str, singular: str, plural: str, n: int) -> str: ...
class NullTranslations(object):
def __init__(self, fp: IO[str] = ...) -> None: ...
def _parse(self, fp: IO[str]) -> None: ...
def add_fallback(self, fallback: NullTranslations) -> None: ...
def gettext(self, message: str) -> str: ...
def lgettext(self, message: str) -> str: ...
def ugettext(self, message: Union[str, unicode]) -> unicode: ...
def ngettext(self, singular: str, plural: str, n: int) -> str: ...
def lngettext(self, singular: str, plural: str, n: int) -> str: ...
def ungettext(self, singular: Union[str, unicode], plural: Union[str, unicode], n: int) -> unicode: ...
def info(self) -> Any: ...
def charset(self) -> Any: ...
def output_charset(self) -> Any: ...
def set_output_charset(self, charset: Any) -> None: ...
def install(self, unicode: bool = ..., names: Any = ...) -> None: ...
class GNUTranslations(NullTranslations):
LE_MAGIC = ... # type: int
BE_MAGIC = ... # type: int
def find(domain: str, localedir: str = ..., languages: List[str] = ...,
all: Any = ...) -> Optional[Union[str, List[str]]]: ...
def translation(domain: str, localedir: str = ..., languages: List[str] = ...,
class_: Any = ..., fallback: Any = ..., codeset: Any = ...) -> NullTranslations: ...
def install(domain: str, localedir: str = ..., unicode: Any = ..., codeset: Any = ...,
names: Any = ...) -> None: ...

4
stdlib/2/glob.pyi Normal file
View File

@@ -0,0 +1,4 @@
from typing import List, Iterator, AnyStr
def glob(pathname: AnyStr) -> List[AnyStr]: ...
def iglob(pathname: AnyStr) -> Iterator[AnyStr]: ...

11
stdlib/2/grp.pyi Normal file
View File

@@ -0,0 +1,11 @@
from typing import Optional, List
class struct_group(object):
gr_name = ... # type: Optional[str]
gr_passwd = ... # type: Optional[str]
gr_gid = ... # type: int
gr_mem = ... # type: List[str]
def getgrall() -> List[struct_group]: ...
def getgrgid(id: int) -> struct_group: ...
def getgrnam(name: str) -> struct_group: ...

41
stdlib/2/gzip.pyi Normal file
View File

@@ -0,0 +1,41 @@
# Stubs for gzip (Python 2)
#
# NOTE: Based on a dynamically typed stub automatically generated by stubgen.
from typing import Any, IO
import io
class GzipFile(io.BufferedIOBase):
myfileobj = ... # type: Any
max_read_chunk = ... # type: Any
mode = ... # type: Any
extrabuf = ... # type: Any
extrasize = ... # type: Any
extrastart = ... # type: Any
name = ... # type: Any
min_readsize = ... # type: Any
compress = ... # type: Any
fileobj = ... # type: Any
offset = ... # type: Any
mtime = ... # type: Any
def __init__(self, filename: str = ..., mode: str = ..., compresslevel: int = ...,
fileobj: IO[str] = ..., mtime: float = ...) -> None: ...
@property
def filename(self): ...
size = ... # type: Any
crc = ... # type: Any
def write(self, data): ...
def read(self, size=...): ...
@property
def closed(self): ...
def close(self): ...
def flush(self, zlib_mode=...): ...
def fileno(self): ...
def rewind(self): ...
def readable(self): ...
def writable(self): ...
def seekable(self): ...
def seek(self, offset, whence=...): ...
def readline(self, size=...): ...
def open(filename: str, mode: str = ..., compresslevel: int = ...) -> GzipFile: ...

27
stdlib/2/hashlib.pyi Normal file
View File

@@ -0,0 +1,27 @@
# Stubs for hashlib (Python 2)
from typing import Tuple
class _hash(object):
# This is not actually in the module namespace.
digest_size = 0
block_size = 0
def update(self, arg: str) -> None: ...
def digest(self) -> str: ...
def hexdigest(self) -> str: ...
def copy(self) -> _hash: ...
def new(name: str, data: str = ...) -> _hash: ...
def md5(s: str = ...) -> _hash: ...
def sha1(s: str = ...) -> _hash: ...
def sha224(s: str = ...) -> _hash: ...
def sha256(s: str = ...) -> _hash: ...
def sha384(s: str = ...) -> _hash: ...
def sha512(s: str = ...) -> _hash: ...
algorithms = ... # type: Tuple[str, ...]
algorithms_guaranteed = ... # type: Tuple[str, ...]
algorithms_available = ... # type: Tuple[str, ...]
def pbkdf2_hmac(name: str, password: str, salt: str, rounds: int, dklen: int = ...) -> str: ...

15
stdlib/2/heapq.pyi Normal file
View File

@@ -0,0 +1,15 @@
from typing import TypeVar, List, Iterable, Any, Callable
_T = TypeVar('_T')
def cmp_lt(x, y) -> bool: ...
def heappush(heap: List[_T], item: _T) -> None: ...
def heappop(heap: List[_T]) -> _T:
raise IndexError() # if heap is empty
def heappushpop(heap: List[_T], item: _T) -> _T: ...
def heapify(x: List[_T]) -> None: ...
def heapreplace(heap: List[_T], item: _T) -> _T:
raise IndexError() # if heap is empty
def merge(*iterables: Iterable[_T]) -> Iterable[_T]: ...
def nlargest(n: int, iterable: Iterable[_T]) -> List[_T]: ...
def nsmallest(n: int, iterable: Iterable[_T]) -> List[_T]: ...

View File

@@ -0,0 +1,9 @@
# Stubs for htmlentitydefs (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from typing import Any, Mapping
name2codepoint = ... # type: Mapping[str, int]
codepoint2name = ... # type: Mapping[int, str]
entitydefs = ... # type: Mapping[str, str]

189
stdlib/2/httplib.pyi Normal file
View File

@@ -0,0 +1,189 @@
# Stubs for httplib (Python 2)
#
# Generated by stubgen and manually massaged a bit.
# Needs lots more work!
from typing import Any, Dict
import mimetools
class HTTPMessage(mimetools.Message):
def addheader(self, key: str, value: str) -> None: ...
def addcontinue(self, key: str, more: str) -> None: ...
dict = ... # type: Dict[str, str]
unixfrom = ... # type: str
headers = ... # type: Any
status = ... # type: str
seekable = ... # type: bool
def readheaders(self) -> None: ...
class HTTPResponse:
fp = ... # type: Any
debuglevel = ... # type: Any
strict = ... # type: Any
msg = ... # type: Any
version = ... # type: Any
status = ... # type: Any
reason = ... # type: Any
chunked = ... # type: Any
chunk_left = ... # type: Any
length = ... # type: Any
will_close = ... # type: Any
def __init__(self, sock, debuglevel=0, strict=0, method=None, buffering:bool=...) -> None: ...
def begin(self): ...
def close(self): ...
def isclosed(self): ...
def read(self, amt=None): ...
def fileno(self): ...
def getheader(self, name, default=None): ...
def getheaders(self): ...
class HTTPConnection:
response_class = ... # type: Any
default_port = ... # type: Any
auto_open = ... # type: Any
debuglevel = ... # type: Any
strict = ... # type: Any
timeout = ... # type: Any
source_address = ... # type: Any
sock = ... # type: Any
def __init__(self, host, port=None, strict=None, timeout=..., source_address=None) -> None: ...
def set_tunnel(self, host, port=None, headers=None): ...
def set_debuglevel(self, level): ...
def connect(self): ...
def close(self): ...
def send(self, data): ...
def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0): ...
def putheader(self, header, *values): ...
def endheaders(self, message_body=None): ...
def request(self, method, url, body=None, headers=...): ...
def getresponse(self, buffering:bool=...): ...
class HTTP:
debuglevel = ... # type: Any
def __init__(self, host:str=..., port=None, strict=None) -> None: ...
def connect(self, host=None, port=None): ...
def getfile(self): ...
file = ... # type: Any
headers = ... # type: Any
def getreply(self, buffering:bool=...): ...
def close(self): ...
class HTTPSConnection(HTTPConnection):
default_port = ... # type: Any
key_file = ... # type: Any
cert_file = ... # type: Any
def __init__(self, host, port=None, key_file=None, cert_file=None, strict=None, timeout=..., source_address=None, context=None) -> None: ...
sock = ... # type: Any
def connect(self): ...
class HTTPS(HTTP):
key_file = ... # type: Any
cert_file = ... # type: Any
def __init__(self, host:str=..., port=None, key_file=None, cert_file=None, strict=None, context=None) -> None: ...
class HTTPException(Exception): ...
class NotConnected(HTTPException): ...
class InvalidURL(HTTPException): ...
class UnknownProtocol(HTTPException):
args = ... # type: Any
version = ... # type: Any
def __init__(self, version) -> None: ...
class UnknownTransferEncoding(HTTPException): ...
class UnimplementedFileMode(HTTPException): ...
class IncompleteRead(HTTPException):
args = ... # type: Any
partial = ... # type: Any
expected = ... # type: Any
def __init__(self, partial, expected=None) -> None: ...
class ImproperConnectionState(HTTPException): ...
class CannotSendRequest(ImproperConnectionState): ...
class CannotSendHeader(ImproperConnectionState): ...
class ResponseNotReady(ImproperConnectionState): ...
class BadStatusLine(HTTPException):
args = ... # type: Any
line = ... # type: Any
def __init__(self, line) -> None: ...
class LineTooLong(HTTPException):
def __init__(self, line_type) -> None: ...
error = ... # type: Any
class LineAndFileWrapper:
def __init__(self, line, file) -> None: ...
def __getattr__(self, attr): ...
def read(self, amt=None): ...
def readline(self): ...
def readlines(self, size=None): ...
# Constants
responses = ... # type: Dict[int, str]
HTTP_PORT = ... # type: int
HTTPS_PORT = ... # type: int
# status codes
# informational
CONTINUE = ... # type: int
SWITCHING_PROTOCOLS = ... # type: int
PROCESSING = ... # type: int
# successful
OK = ... # type: int
CREATED = ... # type: int
ACCEPTED = ... # type: int
NON_AUTHORITATIVE_INFORMATION = ... # type: int
NO_CONTENT = ... # type: int
RESET_CONTENT = ... # type: int
PARTIAL_CONTENT = ... # type: int
MULTI_STATUS = ... # type: int
IM_USED = ... # type: int
# redirection
MULTIPLE_CHOICES = ... # type: int
MOVED_PERMANENTLY = ... # type: int
FOUND = ... # type: int
SEE_OTHER = ... # type: int
NOT_MODIFIED = ... # type: int
USE_PROXY = ... # type: int
TEMPORARY_REDIRECT = ... # type: int
# client error
BAD_REQUEST = ... # type: int
UNAUTHORIZED = ... # type: int
PAYMENT_REQUIRED = ... # type: int
FORBIDDEN = ... # type: int
NOT_FOUND = ... # type: int
METHOD_NOT_ALLOWED = ... # type: int
NOT_ACCEPTABLE = ... # type: int
PROXY_AUTHENTICATION_REQUIRED = ... # type: int
REQUEST_TIMEOUT = ... # type: int
CONFLICT = ... # type: int
GONE = ... # type: int
LENGTH_REQUIRED = ... # type: int
PRECONDITION_FAILED = ... # type: int
REQUEST_ENTITY_TOO_LARGE = ... # type: int
REQUEST_URI_TOO_LONG = ... # type: int
UNSUPPORTED_MEDIA_TYPE = ... # type: int
REQUESTED_RANGE_NOT_SATISFIABLE = ... # type: int
EXPECTATION_FAILED = ... # type: int
UNPROCESSABLE_ENTITY = ... # type: int
LOCKED = ... # type: int
FAILED_DEPENDENCY = ... # type: int
UPGRADE_REQUIRED = ... # type: int
# server error
INTERNAL_SERVER_ERROR = ... # type: int
NOT_IMPLEMENTED = ... # type: int
BAD_GATEWAY = ... # type: int
SERVICE_UNAVAILABLE = ... # type: int
GATEWAY_TIMEOUT = ... # type: int
HTTP_VERSION_NOT_SUPPORTED = ... # type: int
INSUFFICIENT_STORAGE = ... # type: int
NOT_EXTENDED = ... # type: int

35
stdlib/2/imp.pyi Normal file
View File

@@ -0,0 +1,35 @@
"""Stubs for the 'imp' module."""
from typing import List, Optional, Tuple, Iterable, IO, Any
import types
C_BUILTIN = ... # type: int
C_EXTENSION = ... # type: int
IMP_HOOK = ... # type: int
PKG_DIRECTORY = ... # type: int
PY_CODERESOURCE = ... # type: int
PY_COMPILED = ... # type: int
PY_FROZEN = ... # type: int
PY_RESOURCE = ... # type: int
PY_SOURCE = ... # type: int
SEARCH_ERROR = ... # type: int
def acquire_lock() -> None: ...
def find_module(name: str, path: Iterable[str] = ...) -> Optional[Tuple[str, str, Tuple[str, str, int]]]: ...
def get_magic() -> str: ...
def get_suffixes() -> List[Tuple[str, str, int]]: ...
def init_builtin(name: str) -> types.ModuleType: ...
def init_frozen(name: str) -> types.ModuleType: ...
def is_builtin(name: str) -> int: ...
def is_frozen(name: str) -> bool: ...
def load_compiled(name: str, pathname: str, file: IO[Any] = ...) -> types.ModuleType: ...
def load_dynamic(name: str, pathname: str, file: IO[Any] = ...) -> types.ModuleType: ...
def load_module(name: str, file: str, pathname: str, description: Tuple[str, str, int]) -> types.ModuleType: ...
def load_source(name: str, pathname: str, file: IO[Any] = ...) -> types.ModuleType: ...
def lock_held() -> bool: ...
def new_module(name: str) -> types.ModuleType: ...
def release_lock() -> None: ...
class NullImporter:
def __init__(self, path_string: str) -> None: ...
def find_module(fullname: str, path: str = ...) -> None: ...

3
stdlib/2/importlib.pyi Normal file
View File

@@ -0,0 +1,3 @@
import types
def import_module(name: str, package: str = ...) -> types.ModuleType: ...

83
stdlib/2/inspect.pyi Normal file
View File

@@ -0,0 +1,83 @@
# TODO incomplete
from types import TracebackType, FrameType, ModuleType
from typing import Any, Callable, List, Optional, Tuple, Union, NamedTuple
# Types and members
ModuleInfo = NamedTuple('ModuleInfo', [('name', str),
('suffix', str),
('mode', str),
('module_type', int),
])
def getmembers(object: object,
predicate: Callable[[Any], bool] = ...
) -> List[Tuple[str, Any]]: ...
def getmoduleinfo(path: str) -> Optional[ModuleInfo]: ...
def getmodulename(path: str) -> Optional[str]: ...
def ismodule(object: object) -> bool: ...
def isclass(object: object) -> bool: ...
def ismethod(object: object) -> bool: ...
def isfunction(object: object) -> bool: ...
def isisgeneratorfunction(object: object) -> bool: ...
def isgenerator(object: object) -> bool: ...
def istraceback(object: object) -> bool: ...
def isframe(object: object) -> bool: ...
def iscode(object: object) -> bool: ...
def isbuiltin(object: object) -> bool: ...
def isroutine(object: object) -> bool: ...
def isabstract(object: object) -> bool: ...
def ismethoddescriptor(object: object) -> bool: ...
def isdatadescriptor(object: object) -> bool: ...
def isgetsetdescriptor(object: object) -> bool: ...
def ismemberdescriptor(object: object) -> bool: ...
# Retrieving source code
def getdoc(object: object) -> str: ...
def getcomments(object: object) -> str: ...
def getfile(object: object) -> str: ...
def getmodule(object: object) -> ModuleType: ...
def getsourcefile(object: object) -> str: ...
# TODO restrict to "module, class, method, function, traceback, frame,
# or code object"
def getsourcelines(object: object) -> Tuple[List[str], int]: ...
# TODO restrict to "a module, class, method, function, traceback, frame,
# or code object"
def getsource(object: object) -> str: ...
def cleandoc(doc: str) -> str: ...
# Classes and functions
# TODO make the return type more specific
def getclasstree(classes: List[type], unique: bool = ...) -> Any: ...
ArgSpec = NamedTuple('ArgSpec', [('args', List[str]),
('varargs', str),
('keywords', str),
('defaults', tuple),
])
def getargspec(func: object) -> ArgSpec: ...
# TODO make the return type more specific
def getargvalues(frame: FrameType) -> Any: ...
# TODO formatargspec
# TODO formatargvalues
def getmro(cls: type) -> Tuple[type, ...]: ...
# TODO getcallargs
# The interpreter stack
Traceback = NamedTuple('Traceback', [('filename', str),
('lineno', int),
('function', str),
('code_context', List[str]),
('index', int),
])
_FrameRecord = Tuple[FrameType, str, int, str, List[str], int]
def getouterframes(frame: FrameType, context: int = ...) -> List[FrameType]: ...
def getframeinfo(frame: Union[FrameType, TracebackType] , context: int = ...) -> Traceback: ...
def getinnerframes(traceback: TracebackType, context: int = ...) -> List[FrameType]: ...
def currentframe() -> FrameType: ...
def stack(context: int = ...) -> List[_FrameRecord]: ...
def trace(context: int = ...) -> List[_FrameRecord]: ...

105
stdlib/2/io.pyi Normal file
View File

@@ -0,0 +1,105 @@
# Stubs for io
# Based on https://docs.python.org/2/library/io.html
# Only a subset of functionality is included.
DEFAULT_BUFFER_SIZE = 0
from typing import List, BinaryIO, TextIO, IO, overload, Iterator, Iterable, Any, Union
def open(file: Union[str, unicode, int],
mode: unicode = ..., buffering: int = ..., encoding: unicode = ...,
errors: unicode = ..., newline: unicode = ...,
closefd: bool = ...) -> IO[Any]: ...
class IOBase:
# TODO
...
class BytesIO(BinaryIO):
def __init__(self, initial_bytes: str = ...) -> None: ...
# TODO getbuffer
# TODO see comments in BinaryIO for missing functionality
def close(self) -> None: ...
def closed(self) -> bool: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def read(self, n: int = ...) -> str: ...
def readable(self) -> bool: ...
def readline(self, limit: int = ...) -> str: ...
def readlines(self, hint: int = ...) -> List[str]: ...
def seek(self, offset: int, whence: int = ...) -> None: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, size: int = ...) -> int: ...
def writable(self) -> bool: ...
def write(self, s: str) -> None: ...
def writelines(self, lines: Iterable[str]) -> None: ...
def getvalue(self) -> str: ...
def read1(self) -> str: ...
def __iter__(self) -> Iterator[str]: ...
def next(self) -> str: ...
def __enter__(self) -> 'BytesIO': ...
def __exit__(self, type, value, traceback) -> bool: ...
class StringIO(TextIO):
def __init__(self, initial_value: unicode = ...,
newline: unicode = ...) -> None: ...
# TODO see comments in BinaryIO for missing functionality
name = ... # type: str
def close(self) -> None: ...
def closed(self) -> bool: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def read(self, n: int = ...) -> unicode: ...
def readable(self) -> bool: ...
def readline(self, limit: int = ...) -> unicode: ...
def readlines(self, hint: int = ...) -> List[unicode]: ...
def seek(self, offset: int, whence: int = ...) -> None: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, size: int = ...) -> int: ...
def writable(self) -> bool: ...
def write(self, s: unicode) -> None: ...
def writelines(self, lines: Iterable[unicode]) -> None: ...
def getvalue(self) -> unicode: ...
def __iter__(self) -> Iterator[unicode]: ...
def next(self) -> unicode: ...
def __enter__(self) -> 'StringIO': ...
def __exit__(self, type, value, traceback) -> bool: ...
class TextIOWrapper(TextIO):
# write_through is undocumented but used by subprocess
def __init__(self, buffer: IO[str], encoding: unicode = ...,
errors: unicode = ..., newline: unicode = ...,
line_buffering: bool = ...,
write_through: bool = ...) -> None: ...
# TODO see comments in BinaryIO for missing functionality
def close(self) -> None: ...
def closed(self) -> bool: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def read(self, n: int = ...) -> unicode: ...
def readable(self) -> bool: ...
def readline(self, limit: int = ...) -> unicode: ...
def readlines(self, hint: int = ...) -> List[unicode]: ...
def seek(self, offset: int, whence: int = ...) -> None: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def truncate(self, size: int = ...) -> int: ...
def writable(self) -> bool: ...
def write(self, s: unicode) -> None: ...
def writelines(self, lines: Iterable[unicode]) -> None: ...
def __iter__(self) -> Iterator[unicode]: ...
def next(self) -> unicode: ...
def __enter__(self) -> StringIO: ...
def __exit__(self, type, value, traceback) -> bool: ...
class BufferedIOBase(IOBase): ...

87
stdlib/2/itertools.pyi Normal file
View File

@@ -0,0 +1,87 @@
# Stubs for itertools
# Based on https://docs.python.org/2/library/itertools.html
from typing import (Iterator, TypeVar, Iterable, overload, Any, Callable, Tuple,
Union, Sequence, Generic, Optional)
_T = TypeVar('_T')
_S = TypeVar('_S')
def count(start: int = ...,
step: int = ...) -> Iterator[int]: ... # more general types?
def cycle(iterable: Iterable[_T]) -> Iterator[_T]: ...
def repeat(object: _T, times: int = ...) -> Iterator[_T]: ...
def accumulate(iterable: Iterable[_T]) -> Iterator[_T]: ...
class chain(Iterator[_T], Generic[_T]):
def __init__(self, *iterables: Iterable[_T]) -> None: ...
def next(self) -> _T: ...
def __iter__(self) -> Iterator[_T]: ...
@staticmethod
def from_iterable(iterable: Iterable[Iterable[_S]]) -> Iterator[_S]: ...
def compress(data: Iterable[_T], selectors: Iterable[Any]) -> Iterator[_T]: ...
def dropwhile(predicate: Callable[[_T], Any],
iterable: Iterable[_T]) -> Iterator[_T]: ...
def ifilter(predicate: Callable[[_T], Any],
iterable: Iterable[_T]) -> Iterator[_T]: ...
def ifilterfalse(predicate: Callable[[_T], Any],
iterable: Iterable[_T]) -> Iterator[_T]: ...
@overload
def groupby(iterable: Iterable[_T]) -> Iterator[Tuple[_T, Iterator[_T]]]: ...
@overload
def groupby(iterable: Iterable[_T],
key: Callable[[_T], _S]) -> Iterator[Tuple[_S, Iterator[_T]]]: ...
@overload
def islice(iterable: Iterable[_T], stop: int) -> Iterator[_T]: ...
@overload
def islice(iterable: Iterable[_T], start: int, stop: Optional[int],
step: int = ...) -> Iterator[_T]: ...
_T1 = TypeVar('_T1')
_T2 = TypeVar('_T2')
_T3 = TypeVar('_T3')
_T4 = TypeVar('_T4')
@overload
def imap(func: Callable[[_T1], _S], iter1: Iterable[_T1]) -> Iterable[_S]: ...
@overload
def imap(func: Callable[[_T1, _T2], _S],
iter1: Iterable[_T1],
iter2: Iterable[_T2]) -> Iterable[_S]: ... # TODO more than two iterables
def starmap(func: Any, iterable: Iterable[Any]) -> Iterator[Any]: ...
def takewhile(predicate: Callable[[_T], Any],
iterable: Iterable[_T]) -> Iterator[_T]: ...
def tee(iterable: Iterable[Any], n: int = ...) -> Iterator[Any]: ...
@overload
def izip(iter1: Iterable[_T1]) -> Iterable[Tuple[_T1]]: ...
@overload
def izip(iter1: Iterable[_T1],
iter2: Iterable[_T2]) -> Iterable[Tuple[_T1, _T2]]: ...
@overload
def izip(iter1: Iterable[_T1], iter2: Iterable[_T2],
iter3: Iterable[_T3]) -> Iterable[Tuple[_T1, _T2, _T3]]: ...
@overload
def izip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3],
iter4: Iterable[_T4]) -> Iterable[Tuple[_T1, _T2,
_T3, _T4]]: ... # TODO more than four iterables
def izip_longest(*p: Iterable[Any],
fillvalue: Any = ...) -> Iterator[Any]: ...
# TODO: Return type should be Iterator[Tuple[..]], but unknown tuple shape.
# Iterator[Sequence[_T]] loses this type information.
def product(*p: Iterable[_T], repeat: int = ...) -> Iterator[Sequence[_T]]: ...
def permutations(iterable: Iterable[_T],
r: int = ...) -> Iterator[Sequence[_T]]: ...
def combinations(iterable: Iterable[_T],
r: int) -> Iterable[Sequence[_T]]: ...
def combinations_with_replacement(iterable: Iterable[_T],
r: int) -> Iterable[Sequence[_T]]: ...

98
stdlib/2/json.pyi Normal file
View File

@@ -0,0 +1,98 @@
from typing import Any, IO, Optional, Tuple, Callable, Dict, List, Union, Text
class JSONDecodeError(ValueError):
def dumps(self, obj: Any) -> str: ...
def dump(self, obj: Any, fp: IO[str], *args: Any, **kwds: Any) -> None: ...
def loads(self, s: str) -> Any: ...
def load(self, fp: IO[str]) -> Any: ...
def dumps(obj: Any,
skipkeys: bool = ...,
ensure_ascii: bool = ...,
check_circular: bool = ...,
allow_nan: bool = ...,
cls: Any = ...,
indent: Optional[int] = ...,
separators: Optional[Tuple[str, str]] = ...,
encoding: str = ...,
default: Optional[Callable[[Any], Any]] = ...,
sort_keys: bool = ...,
**kwds: Any) -> str: ...
def dump(obj: Any,
fp: IO[str],
skipkeys: bool = ...,
ensure_ascii: bool = ...,
check_circular: bool = ...,
allow_nan: bool = ...,
cls: Any = ...,
indent: Optional[int] = ...,
separators: Optional[Tuple[str, str]] = ...,
encoding: str = ...,
default: Optional[Callable[[Any], Any]] = ...,
sort_keys: bool = ...,
**kwds: Any) -> None: ...
def loads(s: Union[Text, bytes],
encoding: Any = ...,
cls: Any = ...,
object_hook: Callable[[Dict], Any] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
**kwds: Any) -> Any: ...
def load(fp: IO[str],
encoding: Optional[str] = ...,
cls: Any = ...,
object_hook: Callable[[Dict], Any] = ...,
parse_float: Optional[Callable[[str], Any]] = ...,
parse_int: Optional[Callable[[str], Any]] = ...,
parse_constant: Optional[Callable[[str], Any]] = ...,
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
**kwds: Any) -> Any: ...
class JSONDecoder(object):
def __init__(self,
encoding: Union[Text, bytes] = ...,
object_hook: Callable[..., Any] = ...,
parse_float: Callable[[str], float] = ...,
parse_int: Callable[[str], int] = ...,
parse_constant: Callable[[str], Any] = ...,
strict: bool = ...,
object_pairs_hook: Callable[..., Any] = ...) -> None: ...
def decode(self, s: Union[Text, bytes], _w = ...) -> Any: ...
def raw_decode(self,
s: Union[Text, bytes],
idx: int = ...) -> Tuple[Any, Any]: ...
class JSONEncoder(object):
item_separator = ... # type: str
key_separator = ... # type: str
skipkeys = ... # type: bool
ensure_ascii = ... # type: bool
check_circular = ... # type: bool
allow_nan = ... # type: bool
sort_keys = ... # type: bool
indent = ... # type: int
def __init__(self,
skipkeys: bool = ...,
ensure_ascii: bool = ...,
check_circular: bool = ...,
allow_nan: bool = ...,
sort_keys: bool = ...,
indent: int = ...,
separators: Tuple[Union[Text, bytes], Union[Text, bytes]] = ...,
encoding: Union[Text, bytes] = ...,
default: Callable[..., Any] = ...) -> None: ...
def default(self, o: Any) -> Any: ...
def encode(self, o: Any) -> str: ...
def iterencode(self, o: Any, _one_shot: bool = ...) -> str: ...

7
stdlib/2/linecache.pyi Normal file
View File

@@ -0,0 +1,7 @@
# Stubs for linecache (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
def getline(filename, lineno, module_globals=None): ...
def clearcache(): ...
def checkcache(filename=None): ...

9
stdlib/2/markupbase.pyi Normal file
View File

@@ -0,0 +1,9 @@
from typing import Tuple
class ParserBase(object):
def __init__(self) -> None: ...
def error(self, message: str) -> None: ...
def reset(self) -> None: ...
def getpos(self) -> Tuple[int, int]: ...
def unkown_decl(self, data: str) -> None: ...

11
stdlib/2/md5.pyi Normal file
View File

@@ -0,0 +1,11 @@
# Stubs for Python 2.7 md5 stdlib module
class md5(object):
def update(self, arg: str) -> None: ...
def digest(self) -> str: ...
def hexdigest(self) -> str: ...
def copy(self) -> md5: ...
def new(string: str = ...) -> md5: ...
blocksize = 0
digest_size = 0

31
stdlib/2/mimetools.pyi Normal file
View File

@@ -0,0 +1,31 @@
# Stubs for mimetools (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from typing import Any
import rfc822
class Message(rfc822.Message):
encodingheader = ... # type: Any
typeheader = ... # type: Any
def __init__(self, fp, seekable=1): ...
plisttext = ... # type: Any
type = ... # type: Any
maintype = ... # type: Any
subtype = ... # type: Any
def parsetype(self): ...
plist = ... # type: Any
def parseplist(self): ...
def getplist(self): ...
def getparam(self, name): ...
def getparamnames(self): ...
def getencoding(self): ...
def gettype(self): ...
def getmaintype(self): ...
def getsubtype(self): ...
def choose_boundary(): ...
def decode(input, output, encoding): ...
def encode(input, output, encoding): ...
def copyliteral(input, output): ...
def copybinary(input, output): ...

View File

@@ -0,0 +1,32 @@
# Stubs for multiprocessing (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from multiprocessing.process import Process as Process, current_process as current_process, active_children as active_children
from multiprocessing.util import SUBDEBUG as SUBDEBUG, SUBWARNING as SUBWARNING
class ProcessError(Exception): ...
class BufferTooShort(ProcessError): ...
class TimeoutError(ProcessError): ...
class AuthenticationError(ProcessError): ...
def Manager(): ...
def Pipe(duplex=True): ...
def cpu_count(): ...
def freeze_support(): ...
def get_logger(): ...
def log_to_stderr(level=None): ...
def allow_connection_pickling(): ...
def Lock(): ...
def RLock(): ...
def Condition(lock=None): ...
def Semaphore(value=1): ...
def BoundedSemaphore(value=1): ...
def Event(): ...
def Queue(maxsize=0): ...
def JoinableQueue(maxsize=0): ...
def Pool(processes=None, initializer=None, initargs=..., maxtasksperchild=None): ...
def RawValue(typecode_or_type, *args): ...
def RawArray(typecode_or_type, size_or_initializer): ...
def Value(typecode_or_type, *args, **kwds): ...
def Array(typecode_or_type, size_or_initializer, **kwds): ...

View File

@@ -0,0 +1,39 @@
# Stubs for multiprocessing.process (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from typing import Any
def current_process(): ...
def active_children(): ...
class Process:
def __init__(self, group=None, target=None, name=None, args=..., kwargs=...): ...
def run(self): ...
def start(self): ...
def terminate(self): ...
def join(self, timeout=None): ...
def is_alive(self): ...
@property
def name(self): ...
@name.setter
def name(self, name): ...
@property
def daemon(self): ...
@daemon.setter
def daemon(self, daemonic): ...
@property
def authkey(self): ...
@authkey.setter
def authkey(self, authkey): ...
@property
def exitcode(self): ...
@property
def ident(self): ...
pid = ... # type: Any
class AuthenticationString(bytes):
def __reduce__(self): ...
class _MainProcess(Process):
def __init__(self): ...

View File

@@ -0,0 +1,33 @@
# Stubs for multiprocessing.util (Python 2)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from typing import Any
import threading
SUBDEBUG = ... # type: Any
SUBWARNING = ... # type: Any
def sub_debug(msg, *args): ...
def debug(msg, *args): ...
def info(msg, *args): ...
def sub_warning(msg, *args): ...
def get_logger(): ...
def log_to_stderr(level=None): ...
def get_temp_dir(): ...
def register_after_fork(obj, func): ...
class Finalize:
def __init__(self, obj, callback, args=..., kwargs=None, exitpriority=None): ...
def __call__(self, wr=None): ...
def cancel(self): ...
def still_active(self): ...
def is_exiting(): ...
class ForkAwareThreadLock:
def __init__(self): ...
class ForkAwareLocal(threading.local):
def __init__(self): ...
def __reduce__(self): ...

256
stdlib/2/optparse.pyi Normal file
View File

@@ -0,0 +1,256 @@
# Generated by pytype, with only minor tweaks. Might be incomplete.
from typing import Any, Optional, List, Callable, Tuple, Dict, Iterable, Union
# See https://groups.google.com/forum/#!topic/python-ideas/gA1gdj3RZ5g
Text = Union[str, unicode]
NO_DEFAULT = ... # type: Tuple[str, ...]
SUPPRESS_HELP = ... # type: str
SUPPRESS_USAGE = ... # type: str
def check_builtin(option: Option, opt, value: Text) -> Any: ...
def check_choice(option: Option, opt, value) -> Any: ...
def isbasestring(x) -> bool: ...
class OptParseError(Exception):
msg = ... # type: Any
def __init__(self, msg) -> None: ...
class BadOptionError(OptParseError):
__doc__ = ... # type: str
opt_str = ... # type: Any
def __init__(self, opt_str) -> None: ...
class AmbiguousOptionError(BadOptionError):
possibilities = ... # type: Any
def __init__(self, opt_str, possibilities) -> None: ...
class OptionError(OptParseError):
msg = ... # type: Any
option_id = ... # type: str
def __init__(self, msg, option: Option) -> None: ...
class OptionConflictError(OptionError): ...
class HelpFormatter:
NO_DEFAULT_VALUE = ... # type: str
_long_opt_fmt = ... # type: Union[str, unicode]
_short_opt_fmt = ... # type: Union[str, unicode]
current_indent = ... # type: int
default_tag = ... # type: str
help_position = ... # type: Any
help_width = ... # type: Any
indent_increment = ... # type: Any
level = ... # type: int
max_help_position = ... # type: int
option_strings = ... # type: Dict[Option, str]
parser = ... # type: Any
short_first = ... # type: Any
width = ... # type: Any
def __init__(self, indent_increment, max_help_position, width, short_first) -> None: ...
def _format_text(self, text: Text) -> Text: ...
def dedent(self) -> None: ...
def expand_default(self, option: Option) -> Text: ...
def format_description(self, description) -> Any: ...
def format_epilog(self, epilog) -> Any: ...
def format_heading(self, heading) -> Any: ...
def format_option(self, option: Any) -> str: ...
def format_option_strings(self, option: Any) -> Any: ...
def format_usage(self, usage) -> Any: ...
def indent(self) -> None: ...
def set_long_opt_delimiter(self, delim) -> None: ...
def set_parser(self, parser) -> None: ...
def set_short_opt_delimiter(self, delim) -> None: ...
def store_option_strings(self, parser) -> None: ...
class IndentedHelpFormatter(HelpFormatter):
__doc__ = ... # type: str
_long_opt_fmt = ... # type: str
_short_opt_fmt = ... # type: str
current_indent = ... # type: int
default_tag = ... # type: str
help_position = ... # type: int
help_width = ... # type: Optional[int]
indent_increment = ... # type: Any
level = ... # type: int
max_help_position = ... # type: int
option_strings = ... # type: Dict[Any, Any]
parser = ... # type: Optional[OptionParser]
short_first = ... # type: Any
width = ... # type: Any
def __init__(self, *args, **kwargs) -> None: ...
def format_heading(self, heading) -> str: ...
def format_usage(self, usage) -> str: ...
class Option:
ACTIONS = ... # type: Tuple[str, ...]
ALWAYS_TYPED_ACTIONS = ... # type: Tuple[str, ...]
ATTRS = ... # type: List[str]
CHECK_METHODS = ... # type: Union[None, List[Callable]]
CONST_ACTIONS = ... # type: Tuple[str, ...]
STORE_ACTIONS = ... # type: Tuple[str, ...]
TYPED_ACTIONS = ... # type: Tuple[str, ...]
TYPES = ... # type: Tuple[str, ...]
TYPE_CHECKER = ... # type: Dict[str, Callable]
__doc__ = ... # type: str
_long_opts = ... # type: List[Text]
_short_opts = ... # type: List[Text]
action = ... # type: str
dest = ... # type: Any
nargs = ... # type: int
type = ... # type: Any
def __init__(self, *args, **kwargs) -> None: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
def _check_action(self) -> None: ...
def _check_callback(self) -> None: ...
def _check_choice(self) -> None: ...
def _check_const(self) -> None: ...
def _check_dest(self) -> None: ...
def _check_nargs(self) -> None: ...
def _check_opt_strings(self, opts) -> Any: ...
def _check_type(self) -> None: ...
def _set_attrs(self, attrs: Dict[str, Any]) -> None: ...
def _set_opt_strings(self, opts) -> None: ...
def check_value(self, opt, value) -> Any: ...
def convert_value(self, opt, value) -> Any: ...
def get_opt_string(self) -> Text: ...
def process(self, opt, value, values: Any, parser: OptionParser) -> int: ...
def take_action(self, action, dest, opt, value, values, parser: OptionParser) -> int: ...
def takes_value(self) -> bool: ...
make_option = Option
class OptionContainer:
_long_opt = ... # type: Dict[Text, Any]
_short_opt = ... # type: Dict[Text, Any]
conflict_handler = ... # type: Any
defaults = ... # type: Dict[Text, Any]
description = ... # type: Any
option_class = ... # type: Any
def __init__(self, option_class, conflict_handler, description) -> None: ...
def _check_conflict(self, option: Any) -> None: ...
def _create_option_mappings(self) -> None: ...
def _share_option_mappings(self, parser) -> None: ...
def add_option(self, *args, **kwargs) -> Any: ...
def add_options(self, option_list) -> None: ...
def destroy(self) -> None: ...
def format_description(self, formatter: Optional[HelpFormatter]) -> Any: ...
def format_help(self, formatter: HelpFormatter) -> str: ...
def format_option_help(self, formatter: Optional[HelpFormatter]) -> str: ...
def get_description(self) -> Any: ...
def get_option(self, opt_str) -> Optional[Option]: ...
def has_option(self, opt_str) -> bool: ...
def remove_option(self, opt_str) -> None: ...
def set_conflict_handler(self, handler) -> None: ...
def set_description(self, description) -> None: ...
class OptionGroup(OptionContainer):
_long_opt = ... # type: Dict[Any, Any]
_short_opt = ... # type: Dict[Any, Any]
conflict_handler = ... # type: Any
defaults = ... # type: Dict[Text, Any]
description = ... # type: Any
option_class = ... # type: Any
option_list = ... # type: List
parser = ... # type: Any
title = ... # type: Any
def __init__(self, parser, title, *args, **kwargs) -> None: ...
def _create_option_list(self) -> None: ...
def format_help(self, formatter: HelpFormatter) -> Any: ...
def set_title(self, title) -> None: ...
class OptionParser(OptionContainer):
__doc__ = ... # type: str
_long_opt = ... # type: Dict[Text, Any]
_short_opt = ... # type: Dict[Any, Any]
allow_interspersed_args = ... # type: bool
conflict_handler = ... # type: Any
defaults = ... # type: Dict[Any, Any]
description = ... # type: Text
epilog = ... # type: Any
formatter = ... # type: HelpFormatter
largs = ... # type: Union[None, List[Text]]
option_class = ... # type: Callable
option_groups = ... # type: List[OptionParser]
option_list = ... # type: List[Any]
process_default_values = ... # type: Any
prog = ... # type: Any
rargs = ... # type: Optional[List[Any]]
standard_option_list = ... # type: List
usage = ... # type: Optional[Text]
values = ... # type: Any
version = ... # type: Text
def __init__(self, *args, **kwargs) -> None: ...
def _add_help_option(self) -> None: ...
def _add_version_option(self) -> None: ...
def _create_option_list(self) -> None: ...
def _get_all_options(self) -> List[Any]: ...
def _get_args(self, args: Iterable) -> List[Any]: ...
def _get_encoding(self, file) -> Any: ...
def _init_parsing_state(self) -> None: ...
def _match_long_opt(self, opt) -> Any: ...
def _populate_option_list(self, option_list, *args, **kwargs) -> None: ...
def _process_args(self, largs: List[Text], rargs: List, values: Values) -> None: ...
def _process_long_opt(self, rargs: List, values) -> None: ...
def _process_short_opts(self, rargs: List, values) -> None: ...
def add_option_group(self, *args, **kwargs) -> OptionParser: ...
def check_values(self, values, args) -> Tuple[Any, ...]: ...
def disable_interspersed_args(self) -> None: ...
def enable_interspersed_args(self) -> None: ...
def error(self, msg) -> None: ...
def exit(self, *args, **kwargs) -> None: ...
def expand_prog_name(self, s: Optional[Text]) -> Any: ...
def format_epilog(self, formatter: Union[HelpFormatter, OptionParser, None]) -> Any: ...
def format_help(self, *args, **kwargs) -> str: ...
def format_option_help(self, *args, **kwargs) -> str: ...
def get_default_values(self) -> Values: ...
def get_option_group(self, opt_str) -> Any: ...
def get_prog_name(self) -> Any: ...
def get_usage(self) -> Text: ...
def get_version(self) -> Any: ...
def parse_args(self, *args, **kwargs) -> Tuple[Any, ...]: ...
def print_help(self, *args, **kwargs) -> None: ...
def print_usage(self, *args, **kwargs) -> None: ...
def print_version(self, *args, **kwargs) -> None: ...
def set_default(self, dest, value) -> None: ...
def set_defaults(self, *args, **kwargs) -> None: ...
def set_process_default_values(self, process) -> None: ...
def set_usage(self, usage: Text) -> None: ...
class OptionValueError(OptParseError):
__doc__ = ... # type: str
msg = ... # type: Any
class TitledHelpFormatter(HelpFormatter):
__doc__ = ... # type: str
_long_opt_fmt = ... # type: str
_short_opt_fmt = ... # type: str
current_indent = ... # type: int
default_tag = ... # type: str
help_position = ... # type: int
help_width = ... # type: None
indent_increment = ... # type: Any
level = ... # type: int
max_help_position = ... # type: int
option_strings = ... # type: Dict
parser = ... # type: None
short_first = ... # type: Any
width = ... # type: Any
def __init__(self, *args, **kwargs) -> None: ...
def format_heading(self, heading) -> str: ...
def format_usage(self, usage) -> str: ...
class Values:
def __cmp__(self, other) -> int: ...
def __init__(self, *args, **kwargs) -> None: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
def _update(self, dict: Dict[str, Any], mode) -> None: ...
def _update_careful(self, dict: Dict[str, Any]) -> None: ...
def _update_loose(self, dict) -> None: ...
def ensure_value(self, attr, value) -> Any: ...
def read_file(self, filename, *args, **kwargs) -> None: ...
def read_module(self, modname, *args, **kwargs) -> None: ...

302
stdlib/2/os/__init__.pyi Normal file
View File

@@ -0,0 +1,302 @@
# created from https://docs.python.org/2/library/os.html
from typing import (
List, Tuple, Union, Sequence, Mapping, IO, Any, Optional, AnyStr, Iterator,
MutableMapping, NamedTuple, overload
)
from . import path
error = OSError
name = ... # type: str
class _Environ(MutableMapping[str, str]):
def copy(self) -> Dict[str, str]: ...
environ = ... # type: _Environ
def chdir(path: unicode) -> None: ...
def fchdir(fd: int) -> None: ...
def getcwd() -> str: ...
def ctermid() -> str: ...
def getegid() -> int: ...
def geteuid() -> int: ...
def getgid() -> int: ...
def getgroups() -> List[int]: ...
def initgroups(username: str, gid: int) -> None: ...
def getlogin() -> str: ...
def getpgid(pid: int) -> int: ...
def getpgrp() -> int: ...
def getpid() -> int: ...
def getppid() -> int: ...
def getresuid() -> Tuple[int, int, int]: ...
def getresgid() -> Tuple[int, int, int]: ...
def getuid() -> int: ...
def getenv(varname: unicode, value: unicode = ...) -> str: ...
def putenv(varname: unicode, value: unicode) -> None: ...
def setegid(egid: int) -> None: ...
def seteuid(euid: int) -> None: ...
def setgid(gid: int) -> None: ...
def setgroups(groups: Sequence[int]) -> None: ...
# TODO(MichalPokorny)
def setpgrp(*args) -> None: ...
def setpgid(pid: int, pgrp: int) -> None: ...
def setregid(rgid: int, egid: int) -> None: ...
def setresgid(rgid: int, egid: int, sgid: int) -> None: ...
def setresuid(ruid: int, euid: int, suid: int) -> None: ...
def setreuid(ruid: int, euid: int) -> None: ...
def getsid(pid: int) -> int: ...
def setsid() -> None: ...
def setuid(pid: int) -> None: ...
def strerror(code: int) -> str: ...
def umask(mask: int) -> int: ...
def uname() -> Tuple[str, str, str, str, str]: ...
def unsetenv(varname: str) -> None: ...
# TODO(MichalPokorny)
def fdopen(fd: int, *args, **kwargs) -> IO[Any]: ...
def popen(command: str, *args, **kwargs) -> Optional[IO[Any]]: ...
def tmpfile() -> IO[Any]: ...
def tmpnam() -> str: ...
def tempnam(dir: str = ..., prefix: str = ...) -> str: ...
def popen2(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any]]: ...
def popen3(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any], IO[Any]]: ...
def popen4(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any]]: ...
def close(fd: int) -> None: ...
def closerange(fd_low: int, fd_high: int) -> None: ...
def dup(fd: int) -> int: ...
def dup2(fd: int, fd2: int) -> None: ...
def fchmod(fd: int, mode: int) -> None: ...
def fchown(fd: int, uid: int, gid: int) -> None: ...
def fdatasync(fd: int) -> None: ...
def fpathconf(fd: int, name: str) -> None: ...
# TODO(prvak)
def fstat(fd: int) -> Any: ...
def fsync(fd: int) -> None: ...
def ftruncate(fd: int, length: int) -> None: ...
def isatty(fd: int) -> bool: ...
def lseek(fd: int, pos: int, how: int) -> None: ...
SEEK_SET = 0
SEEK_CUR = 0
SEEK_END = 0
# TODO(prvak): maybe file should be unicode? (same with all other paths...)
def open(file: unicode, flags: int, mode: int = ...) -> int: ...
def openpty() -> Tuple[int, int]: ...
def pipe() -> Tuple[int, int]: ...
def read(fd: int, n: int) -> str: ...
def tcgetpgrp(fd: int) -> int: ...
def tcsetpgrp(fd: int, pg: int) -> None: ...
def ttyname(fd: int) -> str: ...
def write(fd: int, str: str) -> int: ...
# TODO: O_*
def access(path: unicode, mode: int) -> bool: ...
F_OK = 0
R_OK = 0
W_OK = 0
X_OK = 0
def getcwdu() -> unicode: ...
def chflags(path: unicode, flags: int) -> None: ...
def chroot(path: unicode) -> None: ...
def chmod(path: unicode, mode: int) -> None: ...
def chown(path: unicode, uid: int, gid: int) -> None: ...
def lchflags(path: unicode, flags: int) -> None: ...
def lchmod(path: unicode, uid: int, gid: int) -> None: ...
def lchown(path: unicode, uid: int, gid: int) -> None: ...
def link(source: unicode, link_name: unicode) -> None: ...
def listdir(path: AnyStr) -> List[AnyStr]: ...
# TODO(MichalPokorny)
def lstat(path: unicode) -> Any: ...
def mkfifo(path: unicode, mode: int = ...) -> None: ...
def mknod(filename: unicode, mode: int = ..., device: int = ...) -> None: ...
def major(device: int) -> int: ...
def minor(device: int) -> int: ...
def makedev(major: int, minor: int) -> int: ...
def mkdir(path: unicode, mode: int = ...) -> None: ...
def makedirs(path: unicode, mode: int = ...) -> None: ...
def pathconf(path: unicode, name: str) -> str: ...
pathconf_names = ... # type: Mapping[str, int]
def readlink(path: AnyStr) -> AnyStr: ...
def remove(path: unicode) -> None: ...
def removedirs(path: unicode) -> None: ...
def rename(src: unicode, dst: unicode) -> None: ...
def renames(old: unicode, new: unicode) -> None: ...
def rmdir(path: unicode) -> None: ...
# TODO(MichalPokorny)
def stat(path: unicode) -> Any: ...
_StatVFS = NamedTuple('_StatVFS', [('f_bsize', int), ('f_frsize', int), ('f_blocks', int),
('f_bfree', int), ('f_bavail', int), ('f_files', int),
('f_ffree', int), ('f_favail', int), ('f_flag', int),
('f_namemax', int)])
def fstatvfs(fd: int) -> _StatVFS: ...
def statvfs(path: unicode) -> _StatVFS: ...
def walk(top: AnyStr, topdown: bool = ..., onerror: Any = ...,
followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr],
List[AnyStr]]]: ...
def symlink(source: unicode, link_name: unicode) -> None: ...
def unlink(path: unicode) -> None: ...
def utime(path: unicode, times: Optional[Tuple[int, int]]) -> None: ...
def abort() -> None: ...
EX_OK = 0 # Unix only
EX_USAGE = 0 # Unix only
EX_DATAERR = 0 # Unix only
EX_NOINPUT = 0 # Unix only
EX_NOUSER = 0 # Unix only
EX_NOHOST = 0 # Unix only
EX_UNAVAILABLE = 0 # Unix only
EX_SOFTWARE = 0 # Unix only
EX_OSERR = 0 # Unix only
EX_OSFILE = 0 # Unix only
EX_CANTCREAT = 0 # Unix only
EX_IOERR = 0 # Unix only
EX_TEMPFAIL = 0 # Unix only
EX_PROTOCOL = 0 # Unix only
EX_NOPERM = 0 # Unix only
EX_CONFIG = 0 # Unix only
def execl(file: AnyStr, *args) -> None: ...
def execle(file: AnyStr, *args) -> None: ...
def execlp(file: AnyStr, *args) -> None: ...
def execlpe(file: AnyStr, *args) -> None: ...
def execvp(file: AnyStr, args: Union[Tuple[AnyStr], List[AnyStr]]) -> None: ...
def execvpe(file: AnyStr, args: Union[Tuple[AnyStr], List[AnyStr]], env: Mapping[AnyStr, AnyStr]) -> None: ...
def execv(path: AnyStr, args: Union[Tuple[AnyStr], List[AnyStr]]) -> None: ...
def execve(path: AnyStr, args: Union[Tuple[AnyStr], List[AnyStr]], env: Mapping[AnyStr, AnyStr]) -> None: ...
def _exit(n: int) -> None: ...
def fork() -> int: ...
def forkpty() -> Tuple[int, int]: ...
def kill(pid: int, sig: int) -> None: ...
def killpg(pgid: int, sig: int) -> None: ...
def nice(increment: int) -> int: ...
# TODO: plock, popen*, P_*
def spawnl(mode: int, path: AnyStr, arg0: AnyStr, *args: AnyStr) -> int: ...
def spawnle(mode: int, path: AnyStr, arg0: AnyStr,
*args: Any) -> int: ... # Imprecise sig
def spawnlp(mode: int, file: AnyStr, arg0: AnyStr,
*args: AnyStr) -> int: ... # Unix only TODO
def spawnlpe(mode: int, file: AnyStr, arg0: AnyStr, *args: Any) -> int:
... # Imprecise signature; Unix only TODO
def spawnv(mode: int, path: AnyStr, args: List[AnyStr]) -> int: ...
def spawnve(mode: int, path: AnyStr, args: List[AnyStr],
env: Mapping[str, str]) -> int: ...
def spawnvp(mode: int, file: AnyStr, args: List[AnyStr]) -> int: ... # Unix only
def spawnvpe(mode: int, file: AnyStr, args: List[AnyStr],
env: Mapping[str, str]) -> int:
... # Unix only
def startfile(path: unicode, operation: str = ...) -> None: ... # Windows only
def system(command: unicode) -> int: ...
def times() -> Tuple[float, float, float, float, float]: ...
def wait() -> Tuple[int, int]: ... # Unix only
def wait3(options: int) -> Tuple[int, int, Any]: ... # Unix only
def wait4(pid: int, options: int) -> Tuple[int, int, Any]: ... # Unix only
def waitpid(pid: int, options: int) -> Tuple[int, int]: ...
def confstr(name: Union[str, int]) -> Optional[str]: ...
confstr_names = ... # type: Mapping[str, int]
def getloadavg() -> Tuple[float, float, float]: ...
def sysconf(name: Union[str, int]) -> int: ...
sysconf_names = ... # type: Mapping[str, int]
curdir = ... # type: str
pardir = ... # type: str
sep = ... # type: str
altsep = ... # type: str
extsep = ... # type: str
pathsep = ... # type: str
defpath = ... # type: str
linesep = ... # type: str
devnull = ... # type: str
def urandom(n: int) -> str: ...
# More constants, copied from stdlib/3/os/__init__.pyi
O_RDONLY = 0
O_WRONLY = 0
O_RDWR = 0
O_APPEND = 0
O_CREAT = 0
O_EXCL = 0
O_TRUNC = 0
O_DSYNC = 0 # Unix only
O_RSYNC = 0 # Unix only
O_SYNC = 0 # Unix only
O_NDELAY = 0 # Unix only
O_NONBLOCK = 0 # Unix only
O_NOCTTY = 0 # Unix only
O_SHLOCK = 0 # Unix only
O_EXLOCK = 0 # Unix only
O_BINARY = 0 # Windows only
O_NOINHERIT = 0 # Windows only
O_SHORT_LIVED = 0# Windows only
O_TEMPORARY = 0 # Windows only
O_RANDOM = 0 # Windows only
O_SEQUENTIAL = 0 # Windows only
O_TEXT = 0 # Windows only
O_ASYNC = 0 # Gnu extension if in C library
O_DIRECT = 0 # Gnu extension if in C library
O_DIRECTORY = 0 # Gnu extension if in C library
O_NOFOLLOW = 0 # Gnu extension if in C library
O_NOATIME = 0 # Gnu extension if in C library
O_LARGEFILE = 0 # Gnu extension if in C library
P_NOWAIT = 0
P_NOWAITO = 0
P_WAIT = 0
#P_DETACH = 0 # Windows only
#P_OVERLAY = 0 # Windows only
# wait()/waitpid() options
WNOHANG = 0 # Unix only
WCONTINUED = 0 # some Unix systems
WUNTRACED = 0 # Unix only
P_ALL = 0
WEXITED = 0
WNOWAIT = 0
TMP_MAX = 0
# Below are Unix-only
def WCOREDUMP(status: int) -> bool: ...
def WEXITSTATUS(status: int) -> int: ...
def WIFCONTINUED(status: int) -> bool: ...
def WIFEXITED(status: int) -> bool: ...
def WIFSIGNALED(status: int) -> bool: ...
def WIFSTOPPED(status: int) -> bool: ...
def WSTOPSIG(status: int) -> int: ...
def WTERMSIG(status: int) -> int: ...
@overload
def stat_float_times(newvalue: bool = ...) -> None: ...
@overload
def stat_float_times() -> bool: ...

65
stdlib/2/os/path.pyi Normal file
View File

@@ -0,0 +1,65 @@
# Stubs for os.path
# Ron Murawski <ron@horizonchess.com>
# based on http://docs.python.org/3.2/library/os.path.html
# adapted for 2.7 by Michal Pokorny
from typing import overload, List, Any, Tuple, BinaryIO, TextIO, TypeVar, Callable, AnyStr
# ----- os.path variables -----
supports_unicode_filenames = False
# aliases (also in os)
curdir = ... # type: str
pardir = ... # type: str
sep = ... # type: str
altsep = ... # type: str
extsep = ... # type: str
pathsep = ... # type: str
defpath = ... # type: str
devnull = ... # type: str
# ----- os.path function stubs -----
def abspath(path: AnyStr) -> AnyStr: ...
def basename(path: AnyStr) -> AnyStr: ...
def commonprefix(list: List[AnyStr]) -> AnyStr: ...
def dirname(path: AnyStr) -> AnyStr: ...
def exists(path: unicode) -> bool: ...
def lexists(path: unicode) -> bool: ...
def expanduser(path: AnyStr) -> AnyStr: ...
def expandvars(path: AnyStr) -> AnyStr: ...
# These return float if os.stat_float_times() == True,
# but int is a subclass of float.
def getatime(path: unicode) -> float: ...
def getmtime(path: unicode) -> float: ...
def getctime(path: unicode) -> float: ...
def getsize(path: unicode) -> int: ...
def isabs(path: unicode) -> bool: ...
def isfile(path: unicode) -> bool: ...
def isdir(path: unicode) -> bool: ...
def islink(path: unicode) -> bool: ...
def ismount(path: unicode) -> bool: ...
def join(path: AnyStr, *paths: AnyStr) -> AnyStr: ...
def normcase(path: AnyStr) -> AnyStr: ...
def normpath(path: AnyStr) -> AnyStr: ...
def realpath(path: AnyStr) -> AnyStr: ...
def relpath(path: AnyStr, start: AnyStr = ...) -> AnyStr: ...
def samefile(path1: unicode, path2: unicode) -> bool: ...
def sameopenfile(fp1: int, fp2: int) -> bool: ...
# TODO
#def samestat(stat1: stat_result,
# stat2: stat_result) -> bool: ... # Unix only
def split(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
def splitdrive(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
def splitunc(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # Windows only, deprecated
_T = TypeVar('_T')
def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ...

30
stdlib/2/pdb.pyi Normal file
View File

@@ -0,0 +1,30 @@
# Stub for pdb (incomplete, only some global functions)
from typing import Any, Dict
def run(statement: str,
globals: Dict[str, Any] = None,
locals: Dict[str, Any] = None) -> None:
...
def runeval(expression: str,
globals: Dict[str, Any] = None,
locals: Dict[str, Any] = None) -> Any:
...
def runctx(statement: str,
globals: Dict[str, Any],
locals: Dict[str, Any]) -> None:
...
def runcall(*args: Any, **kwds: Any) -> Any:
...
def set_trace() -> None:
...
def post_mortem(t: Any = None) -> None:
...
def pm() -> None:
...

38
stdlib/2/pickle.pyi Normal file
View File

@@ -0,0 +1,38 @@
# Stubs for pickle (Python 2)
from typing import Any, BinaryIO
HIGHEST_PROTOCOL = ... # type: int
def dump(obj: Any, file: BinaryIO, protocol: int = None) -> None: ...
def dumps(obj: Any, protocol: int = ...) -> bytes: ...
def load(file: BinaryIO) -> Any: ...
def loads(string: bytes) -> Any: ...
class PickleError(Exception):
pass
class PicklingError(PickleError):
pass
class UnpicklingError(PickleError):
pass
class Pickler:
def __init__(self, file: BinaryIO, protocol: int = None) -> None: ...
def dump(self, obj: Any) -> None: ...
def clear_memo(self) -> None: ...
class Unpickler:
def __init__(self, file: BinaryIO) -> None: ...
def load(self) -> Any: ...

13
stdlib/2/pipes.pyi Normal file
View File

@@ -0,0 +1,13 @@
from typing import Any, IO
class Template:
def __init__(self) -> None: ...
def reset(self) -> None: ...
def clone(self) -> Template: ...
def debug(self, flag: bool) -> None: ...
def append(self, cmd: str, kind: str) -> None: ...
def prepend(self, cmd: str, kind: str) -> None: ...
def open(self, file: str, mode: str) -> IO[Any]: ...
def copy(self, infile: str, outfile: str) -> None: ...
def quote(s: str) -> str: ...

Some files were not shown because too many files have changed in this diff Show More