From 56dcc02e2540b819a071fd63fcbf00d3cb015324 Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Wed, 30 Sep 2015 12:04:57 -0700 Subject: [PATCH] Apply fixes, remove duplicates. Apply fixes to _random, cStringIO, errno, operator, sys, zlib, etc.; also, remove duplicate 2.7/math.pyi, 2.7/marshal.pyi. --- .gitignore | 3 + builtins/2.7/_random.pyi | 11 +- builtins/2.7/binascii.pyi | 30 +++-- builtins/2.7/cStringIO.pyi | 20 +-- builtins/2.7/errno.pyi | 251 ++++++++++++++++++----------------- builtins/2.7/fcntl.pyi | 91 ++++++++++--- builtins/2.7/gc.pyi | 6 +- builtins/2.7/imp.pyi | 38 +++--- builtins/2.7/marshal.pyi | 8 -- builtins/2.7/math.pyi | 52 -------- builtins/2.7/operator.pyi | 124 +++++++++++++++-- builtins/2.7/select.pyi | 171 +++++++++++------------- builtins/2.7/signal.pyi | 94 +++++++------ builtins/2.7/sys.pyi | 207 ++++++++++++----------------- builtins/2.7/thread.pyi | 19 ++- builtins/2.7/time.pyi | 2 +- builtins/2.7/unicodedata.pyi | 66 ++++----- builtins/2.7/zlib.pyi | 22 +-- builtins/3/signal.pyi | 124 +++++++++++------ 19 files changed, 734 insertions(+), 605 deletions(-) delete mode 100644 builtins/2.7/marshal.pyi delete mode 100644 builtins/2.7/math.pyi diff --git a/.gitignore b/.gitignore index db4561eaa..223e8db3a 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,6 @@ docs/_build/ # PyBuilder target/ + +# Local utility scripts +analyze.py diff --git a/builtins/2.7/_random.pyi b/builtins/2.7/_random.pyi index 465053c01..7b5cba32e 100644 --- a/builtins/2.7/_random.pyi +++ b/builtins/2.7/_random.pyi @@ -1,12 +1,9 @@ -# Stubs for _random +from typing import Optional, Any -# NOTE: These are incomplete! - -from typing import Any - -class Random: - def seed(self, x: object = None) -> None: ... +class Random(object): + def __init__(self, seed: x, object = None) -> None: ... def getstate(self) -> tuple: ... def setstate(self, state: tuple) -> None: ... def random(self) -> float: ... def getrandbits(self, k: int) -> int: ... + def jumpahead(self, i: int) -> None: ... diff --git a/builtins/2.7/binascii.pyi b/builtins/2.7/binascii.pyi index d26af165a..a7f149909 100644 --- a/builtins/2.7/binascii.pyi +++ b/builtins/2.7/binascii.pyi @@ -1,20 +1,22 @@ -# Stubs for binascii (Python 2) +"""Stubs for the binascii module.""" + +from typing import Optional -def a2b_uu(string: str) -> str: ... -def b2a_uu(data: str) -> str: ... def a2b_base64(string: str) -> str: ... -def b2a_base64(data: str) -> str: ... -def a2b_qp(string: str, header: bool = None) -> str: ... -def b2a_qp(data: str, quotetabs: bool = None, istext: bool = None, header: bool = None) -> str: ... -def a2b_hqx(string: str) -> str: ... -def rledecode_hqx(data: str) -> str: ... -def rlecode_hqx(data: str) -> str: ... -def b2a_hqx(data: str) -> str: ... -def crc_hqx(data: str, crc: int) -> int: ... -def crc32(data: str, crc: int) -> int: ... -def b2a_hex(data: str) -> str: ... -def hexlify(data: str) -> str: ... def a2b_hex(hexstr: str) -> str: ... +def a2b_hqx(string: str) -> str: ... +def a2b_qp(string: str, header: bool = None) -> 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 = None, istext: bool = None, header: bool = None) -> str: ... +def b2a_uu(data: str) -> str: ... +def crc32(data: str, crc: Optional[int]) -> 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): ... diff --git a/builtins/2.7/cStringIO.pyi b/builtins/2.7/cStringIO.pyi index cdb946242..ac795de49 100644 --- a/builtins/2.7/cStringIO.pyi +++ b/builtins/2.7/cStringIO.pyi @@ -1,10 +1,7 @@ # Stubs for cStringIO (Python 2.7) -# Built from https://docs.python.org/2/library/stringio.html +# See https://docs.python.org/2/library/stringio.html -from typing import IO, List, Iterable, Iterator, Any - -InputType = ... # type: type -OutputType = ... # type: type +from typing import IO, List, Iterable, Iterator, Any, Union class StringIO(IO[str]): softspace = ... # type: int @@ -18,17 +15,24 @@ class StringIO(IO[str]): def flush(self) -> None: ... def isatty(self) -> bool: ... def read(self, size: int = -1) -> str: ... - def write(self, b: str) -> None: ... def readable(self) -> bool: ... def readline(self, size: int = -1) -> str: ... def readlines(self, hint: int = -1) -> List[str]: ... def seek(self, offset: int, whence: int = ...) -> None: ... def seekable(self) -> bool: ... def tell(self) -> int: ... - def truncate(self, size: int = None) -> int: ... + def truncate(self, size: int = None) -> int: + raise IOError() def writable(self) -> bool: ... def writelines(self, lines: Iterable[str]) -> None: ... def next(self) -> str: ... - def __iter__(self) -> Iterator[str]: ... + def __iter__(self) -> "InputType": ... def __enter__(self) -> Any: ... def __exit__(self, exc_type: type, exc_val: Any, exc_tb: Any) -> Any: ... + # only StringO: + def reset() -> None: ... + def write(self, b: Union[str, unicode]) -> None: ... + def writelines(self, lines: Iterable[Union[str, unicode]]) -> None: ... + +InputType = StringIO +OutputType = StringIO diff --git a/builtins/2.7/errno.pyi b/builtins/2.7/errno.pyi index 07e7dc89c..c60170d66 100644 --- a/builtins/2.7/errno.pyi +++ b/builtins/2.7/errno.pyi @@ -1,126 +1,129 @@ -from typing import Mapping +"""Stubs for the 'errno' module.""" -errorcode = ... # type: Mapping[int, str] +from typing import Dict -EPERM = ... # type: int -ENOENT = ... # type: int -ESRCH = ... # type: int -EINTR = ... # type: int -EIO = ... # type: int -ENXIO = ... # type: int -E2BIG = ... # type: int -ENOEXEC = ... # type: int -EBADF = ... # type: int -ECHILD = ... # type: int -EAGAIN = ... # type: int -ENOMEM = ... # type: int -EACCES = ... # type: int -EFAULT = ... # type: int -ENOTBLK = ... # type: int -EBUSY = ... # type: int -EEXIST = ... # type: int -EXDEV = ... # type: int -ENODEV = ... # type: int -ENOTDIR = ... # type: int -EISDIR = ... # type: int -EINVAL = ... # type: int -ENFILE = ... # type: int -EMFILE = ... # type: int -ENOTTY = ... # type: int -ETXTBSY = ... # type: int -EFBIG = ... # type: int -ENOSPC = ... # type: int -ESPIPE = ... # type: int -EROFS = ... # type: int -EMLINK = ... # type: int -EPIPE = ... # type: int -EDOM = ... # type: int -ERANGE = ... # type: int -EDEADLK = ... # type: int -ENAMETOOLONG = ... # type: int -ENOLCK = ... # type: int -ENOSYS = ... # type: int -ENOTEMPTY = ... # type: int -ELOOP = ... # type: int -EWOULDBLOCK = ... # type: int -ENOMSG = ... # type: int -EIDRM = ... # type: int -ECHRNG = ... # type: int -EL2NSYNC = ... # type: int -EL3HLT = ... # type: int -EL3RST = ... # type: int -ELNRNG = ... # type: int -EUNATCH = ... # type: int -ENOCSI = ... # type: int -EL2HLT = ... # type: int -EBADE = ... # type: int -EBADR = ... # type: int -EXFULL = ... # type: int -ENOANO = ... # type: int -EBADRQC = ... # type: int -EBADSLT = ... # type: int -EDEADLOCK = ... # type: int -EBFONT = ... # type: int -ENOSTR = ... # type: int -ENODATA = ... # type: int -ETIME = ... # type: int -ENOSR = ... # type: int -ENONET = ... # type: int -ENOPKG = ... # type: int -EREMOTE = ... # type: int -ENOLINK = ... # type: int -EADV = ... # type: int -ESRMNT = ... # type: int -ECOMM = ... # type: int -EPROTO = ... # type: int -EMULTIHOP = ... # type: int -EDOTDOT = ... # type: int -EBADMSG = ... # type: int -EOVERFLOW = ... # type: int -ENOTUNIQ = ... # type: int -EBADFD = ... # type: int -EREMCHG = ... # type: int -ELIBACC = ... # type: int -ELIBBAD = ... # type: int -ELIBSCN = ... # type: int -ELIBMAX = ... # type: int -ELIBEXEC = ... # type: int -EILSEQ = ... # type: int -ERESTART = ... # type: int -ESTRPIPE = ... # type: int -EUSERS = ... # type: int -ENOTSOCK = ... # type: int -EDESTADDRREQ = ... # type: int -EMSGSIZE = ... # type: int -EPROTOTYPE = ... # type: int -ENOPROTOOPT = ... # type: int -EPROTONOSUPPORT = ... # type: int -ESOCKTNOSUPPORT = ... # type: int -EOPNOTSUPP = ... # type: int -EPFNOSUPPORT = ... # type: int -EAFNOSUPPORT = ... # type: int -EADDRINUSE = ... # type: int -EADDRNOTAVAIL = ... # type: int -ENETDOWN = ... # type: int -ENETUNREACH = ... # type: int -ENETRESET = ... # type: int -ECONNABORTED = ... # type: int -ECONNRESET = ... # type: int -ENOBUFS = ... # type: int -EISCONN = ... # type: int -ENOTCONN = ... # type: int -ESHUTDOWN = ... # type: int -ETOOMANYREFS = ... # type: int -ETIMEDOUT = ... # type: int -ECONNREFUSED = ... # type: int -EHOSTDOWN = ... # type: int -EHOSTUNREACH = ... # type: int -EALREADY = ... # type: int -EINPROGRESS = ... # type: int -ESTALE = ... # type: int -EUCLEAN = ... # type: int -ENOTNAM = ... # type: int -ENAVAIL = ... # type: int -EISNAM = ... # type: int -EREMOTEIO = ... # type: int -EDQUOT = ... # type: int +errorcode = ... # type: Dict[int, str] + +E2BIG = ... # type: int +EACCES = ... # type: int +EADDRINUSE = ... # type: int +EADDRNOTAVAIL = ... # type: int +EADV = ... # type: int +EAFNOSUPPORT = ... # type: int +EAGAIN = ... # type: int +EALREADY = ... # type: int +EBADE = ... # type: int +EBADF = ... # type: int +EBADFD = ... # type: int +EBADMSG = ... # type: int +EBADR = ... # type: int +EBADRQC = ... # type: int +EBADSLT = ... # type: int +EBFONT = ... # type: int +EBUSY = ... # type: int +ECHILD = ... # type: int +ECHRNG = ... # type: int +ECOMM = ... # type: int +ECONNABORTED = ... # type: int +ECONNREFUSED = ... # type: int +ECONNRESET = ... # type: int +EDEADLK = ... # type: int +EDEADLOCK = ... # type: int +EDESTADDRREQ = ... # type: int +EDOM = ... # type: int +EDOTDOT = ... # type: int +EDQUOT = ... # type: int +EEXIST = ... # type: int +EFAULT = ... # type: int +EFBIG = ... # type: int +EHOSTDOWN = ... # type: int +EHOSTUNREACH = ... # type: int +EIDRM = ... # type: int +EILSEQ = ... # type: int +EINPROGRESS = ... # type: int +EINTR = ... # type: int +EINVAL = ... # type: int +EIO = ... # type: int +EISCONN = ... # type: int +EISDIR = ... # type: int +EISNAM = ... # type: int +EL2HLT = ... # type: int +EL2NSYNC = ... # type: int +EL3HLT = ... # type: int +EL3RST = ... # type: int +ELIBACC = ... # type: int +ELIBBAD = ... # type: int +ELIBEXEC = ... # type: int +ELIBMAX = ... # type: int +ELIBSCN = ... # type: int +ELNRNG = ... # type: int +ELOOP = ... # type: int +EMFILE = ... # type: int +EMLINK = ... # type: int +EMSGSIZE = ... # type: int +EMULTIHOP = ... # type: int +ENAMETOOLONG = ... # type: int +ENAVAIL = ... # type: int +ENETDOWN = ... # type: int +ENETRESET = ... # type: int +ENETUNREACH = ... # type: int +ENFILE = ... # type: int +ENOANO = ... # type: int +ENOBUFS = ... # type: int +ENOCSI = ... # type: int +ENODATA = ... # type: int +ENODEV = ... # type: int +ENOENT = ... # type: int +ENOEXEC = ... # type: int +ENOLCK = ... # type: int +ENOLINK = ... # type: int +ENOMEM = ... # type: int +ENOMSG = ... # type: int +ENONET = ... # type: int +ENOPKG = ... # type: int +ENOPROTOOPT = ... # type: int +ENOSPC = ... # type: int +ENOSR = ... # type: int +ENOSTR = ... # type: int +ENOSYS = ... # type: int +ENOTBLK = ... # type: int +ENOTCONN = ... # type: int +ENOTDIR = ... # type: int +ENOTEMPTY = ... # type: int +ENOTNAM = ... # type: int +ENOTSOCK = ... # type: int +ENOTSUP = ... # type: int +ENOTTY = ... # type: int +ENOTUNIQ = ... # type: int +ENXIO = ... # type: int +EOPNOTSUPP = ... # type: int +EOVERFLOW = ... # type: int +EPERM = ... # type: int +EPFNOSUPPORT = ... # type: int +EPIPE = ... # type: int +EPROTO = ... # type: int +EPROTONOSUPPORT = ... # type: int +EPROTOTYPE = ... # type: int +ERANGE = ... # type: int +EREMCHG = ... # type: int +EREMOTE = ... # type: int +EREMOTEIO = ... # type: int +ERESTART = ... # type: int +EROFS = ... # type: int +ESHUTDOWN = ... # type: int +ESOCKTNOSUPPORT = ... # type: int +ESPIPE = ... # type: int +ESRCH = ... # type: int +ESRMNT = ... # type: int +ESTALE = ... # type: int +ESTRPIPE = ... # type: int +ETIME = ... # type: int +ETIMEDOUT = ... # type: int +ETOOMANYREFS = ... # type: int +ETXTBSY = ... # type: int +EUCLEAN = ... # type: int +EUNATCH = ... # type: int +EUSERS = ... # type: int +EWOULDBLOCK = ... # type: int +EXDEV = ... # type: int +EXFULL = ... # type: int diff --git a/builtins/2.7/fcntl.pyi b/builtins/2.7/fcntl.pyi index 0f09a2487..28e8ca50d 100644 --- a/builtins/2.7/fcntl.pyi +++ b/builtins/2.7/fcntl.pyi @@ -1,29 +1,76 @@ from typing import Union import io -FASYNC = 64 +FASYNC = ... # type: int +FD_CLOEXEC = ... # type: int -FD_CLOEXEC = 1 - -F_DUPFD = 0 -F_FULLFSYNC = 51 -F_GETFD = 1 -F_GETFL = 3 -F_GETLK = 7 -F_GETOWN = 5 -F_RDLCK = 1 -F_SETFD = 2 -F_SETFL = 4 -F_SETLK = 8 -F_SETLKW = 9 -F_SETOWN = 6 -F_UNLCK = 2 -F_WRLCK = 3 - -LOCK_EX = 2 -LOCK_NB = 4 -LOCK_SH = 1 -LOCK_UN = 8 +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] diff --git a/builtins/2.7/gc.pyi b/builtins/2.7/gc.pyi index ba5ec1cd6..8eab0cc1b 100644 --- a/builtins/2.7/gc.pyi +++ b/builtins/2.7/gc.pyi @@ -1,4 +1,4 @@ -# Stubs for gc (Python 2) +"""Stubs for the 'gc' module.""" from typing import List, Any, Tuple @@ -6,8 +6,8 @@ def enable() -> None: ... def disable() -> None: ... def isenabled() -> bool: ... def collect(generation: int = None) -> int: ... -def set_debug(flags: Any) -> None: ... -def get_debug() -> Any: ... +def set_debug(flags: int) -> None: ... +def get_debug() -> int: ... def get_objects() -> List[Any]: ... def set_threshold(threshold0: int, threshold1: int = None, threshold2: int = None) -> None: ... def get_count() -> Tuple[int, int, int]: ... diff --git a/builtins/2.7/imp.pyi b/builtins/2.7/imp.pyi index e7e91059d..94d515c76 100644 --- a/builtins/2.7/imp.pyi +++ b/builtins/2.7/imp.pyi @@ -1,34 +1,34 @@ +"""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] = None) -> Optional[Tuple[str, str, Tuple[str, str, int]]]: ... def get_magic() -> str: ... def get_suffixes() -> List[Tuple[str, str, int]]: ... -PY_SOURCE = 0 -PY_COMPILED = 0 -C_EXTENSION = 0 - -def find_module(name: str, path: Iterable[str] = None) -> Optional[Tuple[str, str, Tuple[str, str, int]]]: ... - -# TODO: module object -def load_module(name: str, file: str, pathname: str, description: Tuple[str, str, int]) -> types.ModuleType: ... - -def new_module(name: str) -> types.ModuleType: ... -def lock_held() -> bool: ... -def acquire_lock() -> None: ... -def release_lock() -> None: ... - -PKG_DIRECTORY = 0 -C_BUILTIN = 0 -PY_FROZEN = 0 - -SEARCH_ERROR = 0 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] = None) -> types.ModuleType: ... def load_dynamic(name: str, pathname: str, file: IO[Any] = None) -> 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] = None) -> 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: ... diff --git a/builtins/2.7/marshal.pyi b/builtins/2.7/marshal.pyi deleted file mode 100644 index de83a8e98..000000000 --- a/builtins/2.7/marshal.pyi +++ /dev/null @@ -1,8 +0,0 @@ -from typing import Any, IO - -def dump(value: Any, file: IO[Any], version: int = None) -> None: ... -def load(file: IO[Any]) -> Any: ... -def dumps(value: Any, version: int = None) -> str: ... -def loads(string: str) -> Any: ... - -version = ... # type: int diff --git a/builtins/2.7/math.pyi b/builtins/2.7/math.pyi deleted file mode 100644 index 0abd6b68c..000000000 --- a/builtins/2.7/math.pyi +++ /dev/null @@ -1,52 +0,0 @@ -# Stubs for math -# Ron Murawski - -# based on: http://docs.python.org/2/library/math.html - -from typing import overload, Tuple, Iterable - -# ----- variables and constants ----- -e = 0.0 -pi = 0.0 - -# ----- functions ----- -def ceil(x: float) -> int: ... -def copysign(x: float, y: float) -> float: ... -def fabs(x: float) -> float: ... -def factorial(x: int) -> int: ... -def floor(x: float) -> int: ... -def fmod(x: float, y: float) -> float: ... -def frexp(x: float) -> Tuple[float, int]: ... -def fsum(iterable: Iterable) -> float: ... -def isinf(x: float) -> bool: ... -def isnan(x: float) -> bool: ... -def ldexp(x: float, i: int) -> float: ... -def modf(x: float) -> Tuple[float, float]: ... -def trunc(x: float) -> float: ... -def exp(x: float) -> float: ... -def expm1(x: float) -> float: ... -def log(x: float, base: float = ...) -> float: ... -def log1p(x: float) -> float: ... -def log10(x: float) -> float: ... -def pow(x: float, y: float) -> float: ... -def sqrt(x: float) -> float: ... -def acos(x: float) -> float: ... -def asin(x: float) -> float: ... -def atan(x: float) -> float: ... -def atan2(y: float, x: float) -> float: ... -def cos(x: float) -> float: ... -def hypot(x: float, y: float) -> float: ... -def sin(x: float) -> float: ... -def tan(x: float) -> float: ... -def degrees(x: float) -> float: ... -def radians(x: float) -> float: ... -def acosh(x: float) -> float: ... -def asinh(x: float) -> float: ... -def atanh(x: float) -> float: ... -def cosh(x: float) -> float: ... -def sinh(x: float) -> float: ... -def tanh(x: float) -> float: ... -def erf(x: object) -> float: ... -def erfc(x: object) -> float: ... -def gamma(x: object) -> float: ... -def lgamma(x: object) -> float: ... diff --git a/builtins/2.7/operator.pyi b/builtins/2.7/operator.pyi index bc3919c61..f06724345 100644 --- a/builtins/2.7/operator.pyi +++ b/builtins/2.7/operator.pyi @@ -1,16 +1,124 @@ # Stubs for operator -# NOTE: These are incomplete! - from typing import Any +def __abs__(a: Any) -> Any: ... +def __add__(a: Any, b: Any) -> Any: ... +def __and__(a: Any, b: Any) -> Any: ... +def __concat__(a: Any, b: Any) -> Any: ... +def __contains__(container: Any, item: Any) -> bool: ... +def __delitem__(container: Any, item: Any) -> None: ... +def __delslice__(container: Any, b: int, c: int) -> None: ... +def __div__(a: Any, b: Any) -> Any: ... +def __eq__(a: Any, b: Any) -> Any: ... +def __floordiv__(a: Any, b: Any) -> Any: ... +def __ge__(a: Any, b: Any) -> Any: ... +def __getitem__(container: Any, key: Any) -> Any: ... +def __getslice__(container, b: int, c: int) -> Any: ... +def __gt__(a: Any, b: Any) -> Any: ... +def __iadd__(a: Any, b: Any) -> Any: ... +def __iand__(a: Any, b: Any) -> Any: ... +def __iconcat__(a: Any, b: Any) -> Any: ... +def __idiv__(a: Any, b: Any) -> Any: ... +def __ifloordiv__(a: Any, b: Any) -> Any: ... +def __ilshift__(a: Any, b: Any) -> Any: ... +def __imod__(a: Any, b: Any) -> Any: ... +def __imul__(a: Any, b: Any) -> Any: ... +def __index__(x: Any) -> Any: ... +def __inv__(x: Any) -> Any: ... +def __invert__(x: Any) -> Any: ... +def __ior__(a: Any, b: Any) -> Any: ... +def __ipow__(a: Any, b: Any) -> Any: ... +def __irepeat__(a: Any, b: int) -> Any: ... +def __irshift__(a: Any, b: Any) -> Any: ... +def __isub__(a: Any, b: Any) -> Any: ... +def __itruediv__(a: Any, b: Any) -> Any: ... +def __ixor__(a: Any, b: Any) -> Any: ... +def __le__(a: Any, b: Any) -> Any: ... +def __lshift__(a: Any, b: Any) -> Any: ... +def __lt__(a: Any, b: Any) -> Any: ... +def __mod__(a: Any, b: Any) -> Any: ... +def __mul__(a: Any, b: Any) -> Any: ... +def __ne__(a: Any, b: Any) -> Any: ... +def __neg__(x: Any) -> Any: ... +def __not__(x: Any) -> bool: ... +def __or__(a: Any, b: Any) -> Any: ... +def __pos__(x: Any) -> Any: ... +def __pow__(a: Any, b: Any) -> Any: ... +def __repeat__(a, b: int) -> Any: ... +def __rshift__(a: Any, b: Any) -> Any: ... +def __setitem__(container: Any, b: Any) -> None: ... +def __setslice__(container: Any, b: int, c: int, item: Any) -> None: ... +def __sub__(a: Any, b: Any) -> Any: ... +def __truediv__(a: Any, b: Any) -> Any: ... +def __xor__(a: Any, b: Any) -> Any: ... + +def abs(x: Any) -> Any: ... def add(a: Any, b: Any) -> Any: ... - def and_(a: Any, b: Any) -> Any: ... - -def lt(a: Any, b: Any) -> Any: ... -def le(a: Any, b: Any) -> Any: ... +def concat(a: Any, b: Any) -> Any: ... +def contains(container: Any, item: Any) -> bool: ... +def countOf(container: Any, item: Any) -> int: ... +def delitem(container: Any, item: Any) -> None: ... +def delslice(container: Any, b: int, c: int) -> None: ... +def div(a: Any, b: Any) -> Any: ... def eq(a: Any, b: Any) -> Any: ... -def ne(a: Any, b: Any) -> Any: ... -def gt(a: Any, b: Any) -> Any: ... +def floordiv(a: Any, b: Any) -> Any: ... def ge(a: Any, b: Any) -> Any: ... +def getitem(a: Any, b: Any) -> Any: ... +def getslice(container: Any, b: int, c: int) -> Any: ... +def gt(a: Any, b: Any) -> Any: ... +def iadd(a: Any, b: Any) -> Any: ... +def iand(a: Any, b: Any) -> Any: ... +def iconcat(a: Any, b: Any) -> Any: ... +def idiv(a: Any, b: Any) -> Any: ... +def ifloordiv(a: Any, b: Any) -> Any: ... +def ilshift(a: Any, b: Any) -> Any: ... +def imod(a: Any, b: Any) -> Any: ... +def imul(a: Any, b: Any) -> Any: ... +def index(x: Any) -> Any: ... +def indexOf(container: Any, item: Any) -> int: ... +def inv(x: Any) -> Any: ... +def invert(x: Any) -> Any: ... +def ior(a: Any, b: Any) -> Any: ... +def ipow(a: Any, b: Any) -> Any: ... +def irepeat(a, b: int) -> Any: ... +def irshift(a: Any, b: Any) -> Any: ... +def isCallable(x: Any) -> bool: ... +def isMappingType(x: Any) -> bool: ... +def isNumberType(x: Any) -> bool: ... +def isSequenceType(x: Any) -> bool: ... +def is_(a: Any, b: Any) -> bool: ... +def is_not(a: Any, b: Any) -> bool: ... +def isub(a: Any, b: Any) -> Any: ... +def itruediv(a: Any, b: Any) -> Any: ... +def ixor(a: Any, b: Any) -> Any: ... +def le(a: Any, b: Any) -> Any: ... +def lshift(a: Any, b: Any) -> Any: ... +def lt(a: Any, b: Any) -> Any: ... +def mod(a: Any, b: Any) -> Any: ... +def mul(a: Any, b: Any) -> Any: ... +def ne(a: Any, b: Any) -> Any: ... +def neg(x: Any) -> Any: ... +def not_(x: Any) -> bool: ... +def or_(a: Any, b: Any) -> Any: ... +def pos(x: Any) -> Any: ... +def pow(a: Any, b: Any) -> Any: ... +def repeat(a, b: int) -> Any: ... +def rshift(a: Any, b: Any) -> Any: ... +def sequenceIncludes(seq1: Any, seq2: Any) -> bool: ... +def setitem(container: Any, key: Any, item: Any) -> None: ... +def setslice(container: Any, b: int, c: int, slice: Any) -> None: ... +def sub(a: Any, b: Any) -> Any: ... +def truediv(a: Any, b: Any) -> Any: ... +def truth(x: Any) -> bool: ... +def xor(a: Any, b: Any) -> Any: ... + +class attrgetter(object): + def __init__(self, name: Any): ... + +class itemgetter(object): + def __init__(self, key: Any): ... + +class methodcaller(object): + def __init__(self, method_name: str, *args, **kwargs): ... diff --git a/builtins/2.7/select.pyi b/builtins/2.7/select.pyi index 217fa913b..872564d82 100644 --- a/builtins/2.7/select.pyi +++ b/builtins/2.7/select.pyi @@ -1,109 +1,100 @@ -# Stubs for select (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. +"""Stubs for the 'select' module.""" -from typing import Any +from typing import Any, Optional -KQ_EV_ADD = ... # type: int -KQ_EV_CLEAR = ... # type: int -KQ_EV_DELETE = ... # type: int -KQ_EV_DISABLE = ... # type: int -KQ_EV_ENABLE = ... # type: int -KQ_EV_EOF = ... # type: int -KQ_EV_ERROR = ... # type: int -KQ_EV_FLAG1 = ... # type: int -KQ_EV_ONESHOT = ... # type: int -KQ_EV_SYSFLAGS = ... # type: int -KQ_FILTER_AIO = ... # type: int -KQ_FILTER_PROC = ... # type: int -KQ_FILTER_READ = ... # type: int -KQ_FILTER_SIGNAL = ... # type: int -KQ_FILTER_TIMER = ... # type: int -KQ_FILTER_VNODE = ... # type: int -KQ_FILTER_WRITE = ... # type: int -KQ_NOTE_ATTRIB = ... # type: int -KQ_NOTE_CHILD = ... # type: int -KQ_NOTE_DELETE = ... # type: int -KQ_NOTE_EXEC = ... # type: int -KQ_NOTE_EXIT = ... # type: int -KQ_NOTE_EXTEND = ... # type: int -KQ_NOTE_FORK = ... # type: int -KQ_NOTE_LINK = ... # type: int -KQ_NOTE_LOWAT = ... # type: int -KQ_NOTE_PCTRLMASK = ... # type: int -KQ_NOTE_PDATAMASK = ... # type: int -KQ_NOTE_RENAME = ... # type: int -KQ_NOTE_REVOKE = ... # type: int -KQ_NOTE_TRACK = ... # type: int -KQ_NOTE_TRACKERR = ... # type: int -KQ_NOTE_WRITE = ... # type: int -PIPE_BUF = ... # type: int -POLLERR = ... # type: int -POLLHUP = ... # type: int -POLLIN = ... # type: int -POLLNVAL = ... # type: int -POLLOUT = ... # type: int -POLLPRI = ... # type: int -POLLRDBAND = ... # type: int -POLLRDNORM = ... # type: int -POLLWRBAND = ... # type: int -POLLWRNORM = ... # type: int -EPOLLIN = ... # type: int -EPOLLOUT = ... # type: int -EPOLLPRI = ... # type: int -EPOLLERR = ... # type: int -EPOLLHUP = ... # type: int -EPOLLET = ... # type: int -EPOLLONESHOT = ... # type: int -EPOLLRDNORM = ... # type: int -EPOLLRDBAND = ... # type: int -EPOLLWRNORM = ... # type: int -EPOLLWRBAND = ... # type: int -EPOLLMSG = ... # type: int +EPOLLERR = ... # type: int +EPOLLET = ... # type: int +EPOLLHUP = ... # type: int +EPOLLIN = ... # type: int +EPOLLMSG = ... # type: int +EPOLLONESHOT = ... # type: int +EPOLLOUT = ... # type: int +EPOLLPRI = ... # type: int +EPOLLRDBAND = ... # type: int +EPOLLRDNORM = ... # type: int +EPOLLWRBAND = ... # type: int +EPOLLWRNORM = ... # type: int +EPOLL_RDHUP = ... # type: int +KQ_EV_ADD = ... # type: int +KQ_EV_CLEAR = ... # type: int +KQ_EV_DELETE = ... # type: int +KQ_EV_DISABLE = ... # type: int +KQ_EV_ENABLE = ... # type: int +KQ_EV_EOF = ... # type: int +KQ_EV_ERROR = ... # type: int +KQ_EV_FLAG1 = ... # type: int +KQ_EV_ONESHOT = ... # type: int +KQ_EV_SYSFLAGS = ... # type: int +KQ_FILTER_AIO = ... # type: int +KQ_FILTER_NETDEV = ... # type: int +KQ_FILTER_PROC = ... # type: int +KQ_FILTER_READ = ... # type: int +KQ_FILTER_SIGNAL = ... # type: int +KQ_FILTER_TIMER = ... # type: int +KQ_FILTER_VNODE = ... # type: int +KQ_FILTER_WRITE = ... # type: int +KQ_NOTE_ATTRIB = ... # type: int +KQ_NOTE_CHILD = ... # type: int +KQ_NOTE_DELETE = ... # type: int +KQ_NOTE_EXEC = ... # type: int +KQ_NOTE_EXIT = ... # type: int +KQ_NOTE_EXTEND = ... # type: int +KQ_NOTE_FORK = ... # type: int +KQ_NOTE_LINK = ... # type: int +KQ_NOTE_LINKDOWN = ... # type: int +KQ_NOTE_LINKINV = ... # type: int +KQ_NOTE_LINKUP = ... # type: int +KQ_NOTE_LOWAT = ... # type: int +KQ_NOTE_PCTRLMASK = ... # type: int +KQ_NOTE_PDATAMASK = ... # type: int +KQ_NOTE_RENAME = ... # type: int +KQ_NOTE_REVOKE = ... # type: int +KQ_NOTE_TRACK = ... # type: int +KQ_NOTE_TRACKERR = ... # type: int +KQ_NOTE_WRITE = ... # type: int +PIPE_BUF = ... # type: int +POLLERR = ... # type: int +POLLHUP = ... # type: int +POLLIN = ... # type: int +POLLMSG = ... # type: int +POLLNVAL = ... # type: int +POLLOUT = ... # type: int +POLLPRI = ... # type: int +POLLRDBAND = ... # type: int +POLLRDNORM = ... # type: int +POLLWRBAND = ... # type: int +POLLWRNORM = ... # type: int -def poll(): ... -def select(rlist, wlist, xlist, timeout=...): ... +def poll() -> epoll: ... +def select(rlist, wlist, xlist, timeout: Optional[int]) -> Tuple[List, List, List]: ... -class error(Exception): - characters_written = ... # type: Any - errno = ... # type: Any - filename = ... # type: Any - filename2 = ... # type: Any - strerror = ... # type: Any - def __init__(self, *args, **kwargs): ... - def __reduce__(self): ... +class error(Exception): ... -class kevent: +class kevent(object): data = ... # type: Any - fflags = ... # type: Any - filter = ... # type: Any - flags = ... # type: Any + fflags = ... # type: int + filter = ... # type: int + flags = ... # type: int ident = ... # type: Any udata = ... # type: Any - __hash__ = ... # type: Any def __init__(self, *args, **kwargs): ... - def __eq__(self, other): ... - def __ge__(self, other): ... - def __gt__(self, other): ... - def __le__(self, other): ... - def __lt__(self, other): ... - def __ne__(self, other): ... -class kqueue: - closed = ... # type: Any - def __init__(self, *args, **kwargs): ... - def close(self): ... - def control(self, *args, **kwargs): ... - def fileno(self): ... +class kqueue(object): + closed = ... # type: bool + def __init__(self) -> None: ... + def close(self) -> None: ... + def control(self, changelist: Optional[Iterable[kevent]], max_events: int, timeout: int = ...) -> List[kevent]: ... + def fileno(self) -> int: ... @classmethod - def fromfd(cls, fd): ... + def fromfd(cls, fd: int) -> kqueue: ... -class epoll: +class epoll(object): def __init__(self, sizehint: int = ...) -> None: ... def close(self) -> None: ... def fileno(self) -> int: ... - def fromfd(self, fd): ... def register(self, fd: int, eventmask: int = ...) -> None: ... def modify(self, fd: int, eventmask: int) -> None: ... def unregister(fd: int) -> None: ... def poll(timeout: float = ..., maxevents: int = ...) -> Any: ... + @classmethod + def fromfd(self, fd: int) -> epoll: ... diff --git a/builtins/2.7/signal.pyi b/builtins/2.7/signal.pyi index 06b83ddc1..3f9cdc23a 100644 --- a/builtins/2.7/signal.pyi +++ b/builtins/2.7/signal.pyi @@ -1,60 +1,66 @@ from typing import Callable, Any, Tuple, Union -SIG_DFL = 0 -SIG_IGN = 0 +SIG_DFL = ... # type: long +SIG_IGN = ... # type: long +ITIMER_REAL = ... # type: long +ITIMER_VIRTUAL = ... # type: long +ITIMER_PROF = ... # type: long -SIGABRT = 0 -SIGALRM = 0 -SIGBUS = 0 -SIGCHLD = 0 -SIGCLD = 0 -SIGCONT = 0 -SIGFPE = 0 -SIGHUP = 0 -SIGILL = 0 -SIGINT = 0 -SIGIO = 0 -SIGIOT = 0 -SIGKILL = 0 -SIGPIPE = 0 -SIGPOLL = 0 -SIGPROF = 0 -SIGPWR = 0 -SIGQUIT = 0 -SIGRTMAX = 0 -SIGRTMIN = 0 -SIGSEGV = 0 -SIGSTOP = 0 -SIGSYS = 0 -SIGTERM = 0 -SIGTRAP = 0 -SIGTSTP = 0 -SIGTTIN = 0 -SIGTTOU = 0 -SIGURG = 0 -SIGUSR1 = 0 -SIGUSR2 = 0 -SIGVTALRM = 0 -SIGWINCH = 0 -SIGXCPU = 0 -SIGXFSZ = 0 +SIGABRT = ... # type: int +SIGALRM = ... # type: int +SIGBUS = ... # type: int +SIGCHLD = ... # type: int +SIGCLD = ... # type: int +SIGCONT = ... # type: int +SIGFPE = ... # type: int +SIGHUP = ... # type: int +SIGILL = ... # type: int +SIGINT = ... # type: int +SIGIO = ... # type: int +SIGIOT = ... # type: int +SIGKILL = ... # type: int +SIGPIPE = ... # type: int +SIGPOLL = ... # type: int +SIGPROF = ... # type: int +SIGPWR = ... # type: int +SIGQUIT = ... # type: int +SIGRTMAX = ... # type: int +SIGRTMIN = ... # type: int +SIGSEGV = ... # type: int +SIGSTOP = ... # type: int +SIGSYS = ... # type: int +SIGTERM = ... # type: int +SIGTRAP = ... # type: int +SIGTSTP = ... # type: int +SIGTTIN = ... # type: int +SIGTTOU = ... # type: int +SIGURG = ... # type: int +SIGUSR1 = ... # type: int +SIGUSR2 = ... # type: int +SIGVTALRM = ... # type: int +SIGWINCH = ... # type: int +SIGXCPU = ... # type: int +SIGXFSZ = ... # type: int +NSIG = ... # type: int +# Python 3 only: CTRL_C_EVENT = 0 CTRL_BREAK_EVENT = 0 GSIG = 0 -ITIMER_REAL = 0 -ITIMER_VIRTUAL = 0 -ITIMER_PROF = 0 class ItimerError(IOError): ... _HANDLER = Union[Callable[[int, Any], Any], int, None] -def alarm(time: float) -> int: ... +def alarm(time: int) -> int: ... def getsignal(signalnum: int) -> _HANDLER: ... def pause() -> None: ... def setitimer(which: int, seconds: float, interval: float = None) -> Tuple[float, float]: ... def getitimer(which: int) -> Tuple[float, float]: ... -def set_wakeup_fd(fd: int) -> None: ... -def siginterrupt(signalnum: int, flag: bool) -> None: ... -def signal(signalnum: int, handler: _HANDLER) -> None: ... +def set_wakeup_fd(fd: int) -> long: ... +def siginterrupt(signalnum: int, flag: bool) -> None: + raise RuntimeError() +def signal(signalnum: int, handler: _HANDLER) -> None: + raise RuntimeError() +def default_int_handler(*args, **kwargs) -> Any: + raise KeyboardInterrupt() diff --git a/builtins/2.7/sys.pyi b/builtins/2.7/sys.pyi index de9f26e80..52fffa7e5 100644 --- a/builtins/2.7/sys.pyi +++ b/builtins/2.7/sys.pyi @@ -1,102 +1,39 @@ -# Stubs for sys -# Ron Murawski - -# based on http://docs.python.org/2.7/library/sys.html - -# Partially adapted to Python 2.7 by Jukka Lehtosalo. +"""Stubs for the 'sys' module.""" from typing import ( List, Sequence, Any, Dict, Tuple, BinaryIO, overload ) -# ----- sys variables ----- -abiflags = '' -argv = None # type: List[str] -byteorder = '' -builtin_module_names = None # type: Sequence[str] # actually a tuple of strings -copyright = '' -dllhandle = 0 # Windows only -dont_write_bytecode = False -__displayhook__ = None # type: Any # contains the original value of displayhook -__excepthook__ = None # type: Any # contains the original value of excepthook -exec_prefix = '' -executable = '' -float_repr_style = '' -hexversion = 0 # this is a 32-bit int -last_type = None # type: Any -last_value = None # type: Any -last_traceback = None # type: Any -maxsize = 0 -maxunicode = 0 -meta_path = None # type: List[Any] -modules = None # type: Dict[str, Any] -path = None # type: List[str] -path_hooks = None # type: List[Any] # TODO precise type; function, path to finder -path_importer_cache = None # type: Dict[str, Any] # TODO precise type -platform = '' -prefix = '' -ps1 = '' -ps2 = '' -stdin = None # type: BinaryIO -stdout = None # type: BinaryIO -stderr = None # type: BinaryIO -__stdin__ = None # type: BinaryIO -__stdout__ = None # type: BinaryIO -__stderr__ = None # type: BinaryIO -subversion = None # type: Tuple[str, str, str] -tracebacklimit = 0 -version = '' -api_version = 0 -warnoptions = None # type: Any -# Each entry is a tuple of the form (action, message, category, module, -# lineno) -winver = '' # Windows only -_xoptions = None # type: Dict[Any, Any] - -flags = None # type: _flags class _flags: - debug = 0 - division_warning = 0 - inspect = 0 - interactive = 0 - optimize = 0 - dont_write_bytecode = 0 - no_user_site = 0 - no_site = 0 - ignore_environment = 0 - verbose = 0 - bytes_warning = 0 - quiet = 0 - hash_randomization = 0 + bytes_warning = ... # type: int + debug = ... # type: int + division_new = ... # type: int + division_warning = ... # type: int + dont_write_bytecode = ... # type: int + hash_randomization = ... # type: int + ignore_environment = ... # type: int + inspect = ... # type: int + interactive = ... # type: int + no_site = ... # type: int + no_user_site = ... # type: int + optimize = ... # type: int + py3k_warning = ... # type: int + tabcheck = ... # type: int + unicode = ... # type: int + verbose = ... # type: int -float_info = None # type: _float_info class _float_info: - epsilon = 0.0 # DBL_EPSILON - dig = 0 # DBL_DIG - mant_dig = 0 # DBL_MANT_DIG - max = 0.0 # DBL_MAX - max_exp = 0 # DBL_MAX_EXP - max_10_exp = 0 # DBL_MAX_10_EXP - min = 0.0 # DBL_MIN - min_exp = 0 # DBL_MIN_EXP - min_10_exp = 0 # DBL_MIN_10_EXP - radix = 0 # FLT_RADIX - rounds = 0 # FLT_ROUNDS - -hash_info = None # type: _hash_info -class _hash_info: - width = 0 # width in bits used for hash values - modulus = 0 # prime modulus P used for numeric hash scheme - inf = 0 # hash value returned for a positive infinity - nan = 0 # hash value returned for a nan - imag = 0 # multiplier used for the imaginary part of a complex number - -int_info = None # type: _int_info -class _int_info: - bits_per_digit = 0 # number of bits held in each digit. Python integers - # are stored internally in - # base 2**int_info.bits_per_digit - sizeof_digit = 0 # size in bytes of C type used to represent a digit + max = ... # type: float + max_exp = ... # type: int + max_10_exp = ... # type: int + min = ... # type: float + min_exp = ... # type: int + min_10_exp = ... # type: int + dig = ... # type: int + mant_dig = ... # type: int + epsilon = ... # type: float + radix = ... # type: int + rounds = ... # type: int class _version_info(Tuple[int, int, int, str, int]): major = 0 @@ -104,49 +41,73 @@ class _version_info(Tuple[int, int, int, str, int]): micro = 0 releaselevel = '' serial = 0 -version_info = None # type: _version_info -# ----- sys function stubs ----- -def call_tracing(fn: Any, args: Any) -> object: ... +_mercurial = ... # type: tuple +api_version = ... # type: int +argv = ... # type: List[str] +builtin_module_names = ... # type: List[str] +byteorder = ... # type: str +copyright = ... # type: str +dont_write_bytecode = ... # type: bool +exec_prefix = ... # type: str +executable = ... # type: str +flags = ... # type: _flags +float_repr_style = ... # type: str +hexversion = ... # type: int +long_info = ... # type: object +maxint = ... # type: int +maxsize = ... # type: int +maxunicode = ... # type: int +modules = ... # type: Dict[str, module] +path = ... # type: List[str] +platform = ... # type: str +prefix = ... # type: str +py3kwarning = ... # type: bool +stderr = ... # type: file +stdin = ... # type: file +stdout = ... # type: file +subversion = ... # type: tuple +version = ... # type: str +version_info = ... # type: Tuple[int] +warnoptions = ... # type: object +float_info = ... # type: _float_info +version_info = ... # type: _version_info + +class _WindowsVersionType: + major = ... # type: Any + minor = ... # type: Any + build = ... # type: Any + platform = ... # type: Any + service_pack = ... # type: Any + service_pack_major = ... # type: Any + service_pack_minor = ... # type: Any + suite_mask = ... # type: Any + product_type = ... # type: Any + +def getwindowsversion() -> _WindowsVersionType: ... # TODO return type + def _clear_type_cache() -> None: ... def _current_frames() -> Dict[int, Any]: ... +def _getframe(depth: int = ...) -> Any: ... # TODO: Return FrameObject +def call_tracing(fn: Any, args: Any) -> Any: ... def displayhook(value: int) -> None: ... # value might be None -def excepthook(type_: type, value: BaseException, traceback: Any) -> None: - # TODO traceback type - ... -def exc_info() -> Tuple[type, Any, Any]: ... # see above -def exit(arg: int = 0) -> None: ... # arg might be None +def excepthook(type_: type, value: BaseException, traceback: Any) -> None: ... # TODO traceback type +def exc_clear() -> None: + raise DeprecationWarning() +def exc_info() -> Tuple[type, Any, Any]: ... # TODO traceback type +def exit(arg: int = ...) -> None: + raise SystemExit() def getcheckinterval() -> int: ... # deprecated def getdefaultencoding() -> str: ... def getdlopenflags() -> int: ... -def getfilesystemencoding() -> str: ... +def getfilesystemencoding() -> Union[str, None]: ... def getrefcount(object) -> int: ... def getrecursionlimit() -> int: ... - -@overload -def getsizeof(obj: object) -> int: ... -@overload -def getsizeof(obj: object, default: int) -> int: ... - -def getswitchinterval() -> float: ... - -@overload -def _getframe() -> Any: ... -@overload -def _getframe(depth: int) -> Any: ... - -def getprofile() -> Any: ... # TODO return type -def gettrace() -> Any: ... # TODO return -def getwindowsversion() -> Any: ... # TODO return type -def intern(string: str) -> str: ... +def getsizeof(obj: object, default: int = ...) -> int: ... +def getprofile() -> None: ... +def gettrace() -> None: ... def setcheckinterval(interval: int) -> None: ... # deprecated def setdlopenflags(n: int) -> None: ... def setprofile(profilefunc: Any) -> None: ... # TODO type def setrecursionlimit(limit: int) -> None: ... -def setswitchinterval(interval: float) -> None: ... def settrace(tracefunc: Any) -> None: ... # TODO type -# Trace functions should have three arguments: frame, event, and arg. frame -# is the current stack frame. event is a string: 'call', 'line', 'return', -# 'exception', 'c_call', 'c_return', or 'c_exception'. arg depends on the -# event type. -def settscdump(on_flag: bool) -> None: ... diff --git a/builtins/2.7/thread.pyi b/builtins/2.7/thread.pyi index 062d56d84..8c2a8d48c 100644 --- a/builtins/2.7/thread.pyi +++ b/builtins/2.7/thread.pyi @@ -1,16 +1,33 @@ +"""Stubs for the "thread" module.""" from typing import Callable, Any +def _count() -> int: ... + class error(Exception): ... + class LockType: def acquire(self, waitflag: int = None) -> bool: ... + def acquire_lock(self, waitflag: int = None) -> bool: ... def release(self) -> None: ... + def release_lock(self) -> None: ... def locked(self) -> bool: ... + def locked_lock(self) -> bool: ... def __enter__(self) -> LockType: ... def __exit__(self, value: Any, traceback: Any) -> None: ... +class _local(object): + pass + +class _localdummy(object): + pass + +def start_new(function: Callable[..., Any], args: Any, kwargs: Any = None) -> int: ... def start_new_thread(function: Callable[..., Any], args: Any, kwargs: Any = None) -> int: ... def interrupt_main() -> None: ... -def exit() -> None: ... +def exit() -> None: + raise SystemExit() +def exit_thread() -> Any: + raise SystemExit() def allocate_lock() -> LockType: ... def get_ident() -> int: ... def stack_size(size: int = None) -> int: ... diff --git a/builtins/2.7/time.pyi b/builtins/2.7/time.pyi index be01b0e38..265dc0612 100644 --- a/builtins/2.7/time.pyi +++ b/builtins/2.7/time.pyi @@ -1,5 +1,5 @@ """Stub file for the 'time' module.""" -# based on autogenerated stub from typeshed and https://docs.python.org/2/library/time.html +# See https://docs.python.org/2/library/time.html from typing import NamedTuple, Tuple, Union diff --git a/builtins/2.7/unicodedata.pyi b/builtins/2.7/unicodedata.pyi index fd7bb6027..9e3be51be 100644 --- a/builtins/2.7/unicodedata.pyi +++ b/builtins/2.7/unicodedata.pyi @@ -1,37 +1,39 @@ -# Stubs for unicodedata (Python 2.7) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. +"""Stubs for the 'unicodedata' module.""" -from typing import Any +from typing import Any, TypeVar -ucd_3_2_0 = ... # type: Any -ucnhash_CAPI = ... # type: Any +ucd_3_2_0 = ... # type: UCD +ucnhash_CAPI = ... # type: Any (PyCapsule) unidata_version = ... # type: str -def bidirectional(unichr): ... -def category(unichr): ... -def combining(unichr): ... -def decimal(chr, default=...): ... -def decomposition(unichr): ... -def digit(chr, default=...): ... -def east_asian_width(unichr): ... -def lookup(name): ... -def mirrored(unichr): ... -def name(chr, default=...): ... -def normalize(form: str, unistr: unicode) -> unicode: ... -def numeric(chr, default=...): ... +_default = TypeVar("default") -class UCD: - unidata_version = ... # type: Any - def bidirectional(self, unichr): ... - def category(self, unichr): ... - def combining(self, unichr): ... - def decimal(self, chr, default=...): ... - def decomposition(self, unichr): ... - def digit(self, chr, default=...): ... - def east_asian_width(self, unichr): ... - def lookup(self, name): ... - def mirrored(self, unichr): ... - def name(self, chr, default=...): ... - def normalize(self, form, unistr): ... - def numeric(self, chr, default=...): ... +def bidirectional(unichr: unicode) -> str: ... +def category(unichr: unicode) -> str: ... +def combining(unichr: unicode) -> int: ... +def decimal(chr: unicode, default=_default) -> Union[int, _default]: ... +def decomposition(unichr: unicode) -> str: ... +def digit(chr: unicode, default=_default) -> Union[int, _default]: ... +def east_asian_width(unichr: unicode): str +def lookup(name: str): unicode +def mirrored(unichr: unicode): int +def name(chr: unicode, default=_default) -> Union[str, _default]: ... +def normalize(form: str, unistr: unicode) -> unicode: ... +def numeric(chr, default=_default): Union[float, _default]: ... + +class UCD(object): + unidata_version = ... # type: str + # The methods below are constructed from the same array in C + # (unicodedata_functions) and hence identical to the methods above. + def bidirectional(unichr: unicode) -> str: ... + def category(unichr: unicode) -> str: ... + def combining(unichr: unicode) -> int: ... + def decimal(chr: unicode, default=_default) -> Union[int, _default]: ... + def decomposition(unichr: unicode) -> str: ... + def digit(chr: unicode, default=_default) -> Union[int, _default]: ... + def east_asian_width(unichr: unicode): str + def lookup(name: str): unicode + def mirrored(unichr: unicode): int + def name(chr: unicode, default=_default) -> Union[str, _default]: ... + def normalize(form: str, unistr: unicode) -> unicode: ... + def numeric(chr, default=_default): Union[float, _default]: ... diff --git a/builtins/2.7/zlib.pyi b/builtins/2.7/zlib.pyi index df0fa1e84..74eeed33e 100644 --- a/builtins/2.7/zlib.pyi +++ b/builtins/2.7/zlib.pyi @@ -1,6 +1,6 @@ # Stubs for zlib (Python 2.7) -# -# NOTE: This stub was automatically generated by stubgen. + +class error(Exception): ... DEFLATED = ... # type: int DEF_MEM_LEVEL = ... # type: int @@ -19,12 +19,18 @@ Z_SYNC_FLUSH = ... # type: int def adler32(data: str, value: int = ...) -> int: ... def compress(data: str, level: int = ...) -> str: ... -# TODO: compressobj() returns a compress object -def compressobj(level: int = ..., method: int = ..., wbits: int = ..., memlevel: int = ..., - strategy: int = ...): ... def crc32(data: str, value: int = ...) -> int: ... def decompress(data: str, wbits: int = ..., bufsize: int = ...) -> str: ... -# TODO: decompressobj() returns a decompress object -def decompressobj(wbits: int = ...): ... -class error(Exception): ... +class compressobj: + def __init__(level: int = ..., method: int = ..., wbits: int = ..., memlevel: int = ..., + strategy: int = ...): ... + def compress(self, data: str) -> str: ... + def copy(self) -> _Compress: ... + def flush(self) -> NoneType: ... + +class decompressobj: + def __init__(wbits: int = ...): ... + def copy(self) -> _Compress: ... + def decompress(self, data: str) -> str: ... + def flush(self) -> NoneType: ... diff --git a/builtins/3/signal.pyi b/builtins/3/signal.pyi index 31ddb10b2..2040482c5 100644 --- a/builtins/3/signal.pyi +++ b/builtins/3/signal.pyi @@ -1,51 +1,93 @@ -# Stubs for signal +"""Stub file for the 'signal' module.""" -# Based on http://docs.python.org/3.2/library/signal.html +from typing import Any, Callable, List, Tuple, Dict, Generic, Union -from typing import Any, overload, Callable +class ItimerError(IOError): ... -SIG_DFL = 0 -SIG_IGN = 0 - -# TODO more SIG* constants (these should be platform specific?) -SIGHUP = 0 -SIGINT = 0 -SIGQUIT = 0 -SIGABRT = 0 -SIGKILL = 0 -SIGALRM = 0 -SIGTERM = 0 - -SIGUSR1 = 0 -SIGUSR2 = 0 -SIGCONT = 0 -SIGSTOP = 0 - -SIGPOLL = 0 -SIGVTALRM = 0 +ITIMER_PROF = ... # type: int +ITIMER_REAL = ... # type: int +ITIMER_VIRTUAL = ... # type: int +NSIG = ... # type: int +SIGABRT = ... # type: int +SIGALRM = ... # type: int +SIGBUS = ... # type: int +SIGCHLD = ... # type: int +SIGCLD = ... # type: int +SIGCONT = ... # type: int +SIGFPE = ... # type: int +SIGHUP = ... # type: int +SIGILL = ... # type: int +SIGINT = ... # type: int +SIGIO = ... # type: int +SIGIOT = ... # type: int +SIGKILL = ... # type: int +SIGPIPE = ... # type: int +SIGPOLL = ... # type: int +SIGPROF = ... # type: int +SIGPWR = ... # type: int +SIGQUIT = ... # type: int +SIGRTMAX = ... # type: int +SIGRTMIN = ... # type: int +SIGSEGV = ... # type: int +SIGSTOP = ... # type: int +SIGSYS = ... # type: int +SIGTERM = ... # type: int +SIGTRAP = ... # type: int +SIGTSTP = ... # type: int +SIGTTIN = ... # type: int +SIGTTOU = ... # type: int +SIGURG = ... # type: int +SIGUSR1 = ... # type: int +SIGUSR2 = ... # type: int +SIGVTALRM = ... # type: int +SIGWINCH = ... # type: int +SIGXCPU = ... # type: int +SIGXFSZ = ... # type: int +SIG_DFL = ... # type: int +SIG_IGN = ... # type: int CTRL_C_EVENT = 0 # Windows CTRL_BREAK_EVENT = 0 # Windows -NSIG = 0 -ITIMER_REAL = 0 -ITIMER_VIRTUAL = 0 -ITIMER_PROF = 0 +def alarm(time: int) -> int: ... -class ItimerError(IOError): ... +def default_int_handler(*args, **kwargs) -> Any: + raise KeyboardInterrupt() -def alarm(time: int) -> int: ... # Unix -def getsignal(signalnum: int) -> Any: ... -def pause() -> None: ... # Unix -#def setitimer(which: int, seconds: float, -# internval: float = None) -> Tuple[float, float]: ... # Unix -#def getitimer(int which): ... # Unix -def set_wakeup_fd(fd: int) -> None: ... -def siginterrupt(signalnum: int, flag: bool) -> None: ... +def getitimer(which: int) -> tuple: ... -@overload -def signal(signalnum: int, handler: int) -> Any: ... -@overload -def signal(signalnum: int, - handler: Callable[[int, Any], None]) -> Any: - ... # TODO frame object type +def getsignal(signalnum: int) -> None: + raise ValueError() + +def pause() -> None: ... + +def pthread_kill(a: int, b: int) -> None: + raise OSError() + +def pthread_sigmask(a: int, b) -> Any: + raise OSError() + +def set_wakeup_fd(fd: int) -> int: ... + +def setitimer(which: int, seconds: float, internval: float = ...) -> Tuple[float, float]: ... + +def siginterrupt(signalnum: int, flag: int) -> None: + raise OSError() + +def signal(signalnum: int, handler: Union[int, Callable[[int, Any], None]]) -> Any: + raise OSError() + +def sigpending() -> Any: + raise OSError() + +def sigtimedwait(a, b) -> Any: + raise OSError() + raise ValueError() + +def sigwait(a) -> int: + raise OSError() + +def sigwaitinfo(a) -> tuple: + raise OSError() + +... # TODO frame object type