Add binascii, errno, fcntl, imp, marshal, select, sys, unicodedata.

Some stubs inspired or adapted from mypy stubs.
This commit is contained in:
Matthias Kramm
2015-09-16 15:30:08 -07:00
parent 199abc980c
commit 9cbe15e57f
8 changed files with 533 additions and 0 deletions

23
2.7/binascii.pyi Normal file
View File

@@ -0,0 +1,23 @@
"""Stubs for the binascii module."""
from typing import Optional
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 = 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): ...
class Incomplete(Exception): ...

129
2.7/errno.pyi Normal file
View File

@@ -0,0 +1,129 @@
"""Stubs for the 'errno' module."""
from typing import Dict
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

85
2.7/fcntl.pyi Normal file
View File

@@ -0,0 +1,85 @@
from typing import 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]
def fcntl(fd: _ANYFILE, op: int, arg: Union[int, str] = 0) -> Union[int, str]: ...
# TODO: arg: int or read-only buffer interface or read-write buffer interface
def ioctl(fd: _ANYFILE, op: int, arg: Union[int, str] = 0,
mutate_flag: bool = True) -> Union[int, str]: ...
def flock(fd: _ANYFILE, op: int) -> None: ...
def lockf(fd: _ANYFILE, op: int, length: int = 0, start: int = 0,
whence: int = 0) -> Union[int, str]: ...

35
2.7/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] = None) -> 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] = 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: ...
def find_module(fullname: str, path: str = None) -> None: ...

8
2.7/marshal.pyi Normal file
View File

@@ -0,0 +1,8 @@
from typing import Any, IO
version = ... # type: int
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: ...

101
2.7/select.pyi Normal file
View File

@@ -0,0 +1,101 @@
"""Stubs for the 'select' module."""
from typing import Any, Optional
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() -> epoll: ...
def select(rlist, wlist, xlist, timeout: Optional[int]) -> Tuple[List, List, List]: ...
class error(Exception): ...
class kevent(object):
data = ... # type: Any
fflags = ... # type: int
filter = ... # type: int
flags = ... # type: int
ident = ... # type: Any
udata = ... # type: Any
def __init__(self, *args, **kwargs): ...
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: int) -> kqueue: ...
class epoll(object):
def __init__(self, sizehint: int = ...) -> None: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
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: ...

113
2.7/sys.pyi Normal file
View File

@@ -0,0 +1,113 @@
"""Stubs for the 'sys' module."""
from typing import (
List, Sequence, Any, Dict, Tuple, BinaryIO, overload
)
class _flags:
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
class _float_info:
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
minor = 0
micro = 0
releaselevel = ''
serial = 0
_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_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() -> Union[str, None]: ...
def getrefcount(object) -> int: ...
def getrecursionlimit() -> int: ...
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 settrace(tracefunc: Any) -> None: ... # TODO type

39
2.7/unicodedata.pyi Normal file
View File

@@ -0,0 +1,39 @@
"""Stubs for the 'unicodedata' module."""
from typing import Any, TypeVar
ucd_3_2_0 = ... # type: UCD
ucnhash_CAPI = ... # type: Any (PyCapsule)
unidata_version = ... # type: str
_default = TypeVar("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]: ...