merge 2and3 stubs for select (#1333)

There don't seem to be significant changes between Python 2 and 3. The Python 2
stub was much better, so I mostly built off of it.
This commit is contained in:
Jelle Zijlstra
2017-05-24 14:57:11 -07:00
committed by Guido van Rossum
parent 6152bad0af
commit 6fe7cdb1c3
3 changed files with 137 additions and 127 deletions

View File

@@ -1,100 +0,0 @@
"""Stubs for the 'select' module."""
from typing import Any, Optional, Tuple, Iterable, List
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: float = None) -> 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) -> None: ...
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(self, fd: int) -> None: ...
def poll(self, timeout: float = ..., maxevents: int = ...) -> Any: ...
@classmethod
def fromfd(cls, fd: int) -> epoll: ...

137
stdlib/2and3/select.pyi Normal file
View File

@@ -0,0 +1,137 @@
import sys
from typing import Any, Optional, Sequence, Tuple, Iterable, List, Union
# When we have protocols, this should change to a protocol with a fileno method
# See https://docs.python.org/3/c-api/file.html#c.PyObject_AsFileDescriptor
_FileDescriptor = Union[int, Any]
EPOLLERR: int
EPOLLET: int
EPOLLHUP: int
EPOLLIN: int
EPOLLMSG: int
EPOLLONESHOT: int
EPOLLOUT: int
EPOLLPRI: int
EPOLLRDBAND: int
EPOLLRDNORM: int
EPOLLWRBAND: int
EPOLLWRNORM: int
EPOLL_RDHUP: int
KQ_EV_ADD: int
KQ_EV_CLEAR: int
KQ_EV_DELETE: int
KQ_EV_DISABLE: int
KQ_EV_ENABLE: int
KQ_EV_EOF: int
KQ_EV_ERROR: int
KQ_EV_FLAG1: int
KQ_EV_ONESHOT: int
KQ_EV_SYSFLAGS: int
KQ_FILTER_AIO: int
KQ_FILTER_NETDEV: int
KQ_FILTER_PROC: int
KQ_FILTER_READ: int
KQ_FILTER_SIGNAL: int
KQ_FILTER_TIMER: int
KQ_FILTER_VNODE: int
KQ_FILTER_WRITE: int
KQ_NOTE_ATTRIB: int
KQ_NOTE_CHILD: int
KQ_NOTE_DELETE: int
KQ_NOTE_EXEC: int
KQ_NOTE_EXIT: int
KQ_NOTE_EXTEND: int
KQ_NOTE_FORK: int
KQ_NOTE_LINK: int
KQ_NOTE_LINKDOWN: int
KQ_NOTE_LINKINV: int
KQ_NOTE_LINKUP: int
KQ_NOTE_LOWAT: int
KQ_NOTE_PCTRLMASK: int
KQ_NOTE_PDATAMASK: int
KQ_NOTE_RENAME: int
KQ_NOTE_REVOKE: int
KQ_NOTE_TRACK: int
KQ_NOTE_TRACKERR: int
KQ_NOTE_WRITE: int
PIPE_BUF: int
POLLERR: int
POLLHUP: int
POLLIN: int
POLLMSG: int
POLLNVAL: int
POLLOUT: int
POLLPRI: int
POLLRDBAND: int
POLLRDNORM: int
POLLWRBAND: int
POLLWRNORM: int
class poll:
def __init__(self) -> None: ...
def register(self, fd: _FileDescriptor, eventmask: int = ...) -> None: ...
def modify(self, fd: _FileDescriptor, eventmask: int) -> None: ...
def unregister(self, fd: _FileDescriptor) -> None: ...
def poll(self, timeout: Optional[float] = ...) -> List[Tuple[int, int]]: ...
def select(rlist: Sequence[Any], wlist: Sequence[Any], xlist: Sequence[Any],
timeout: Optional[float] = ...) -> Tuple[List[Any],
List[Any],
List[Any]]: ...
if sys.version_info >= (3, 3):
error = OSError
else:
class error(Exception): ...
# BSD only
class kevent(object):
data: Any
fflags: int
filter: int
flags: int
ident: int
udata: Any
def __init__(self, ident: _FileDescriptor, filter: int = ..., flags: int = ..., fflags: int = ..., data: Any = ..., udata: Any = ...) -> None: ...
# BSD only
class kqueue(object):
closed: bool
def __init__(self) -> None: ...
def close(self) -> None: ...
def control(self, changelist: Optional[Iterable[kevent]], max_events: int, timeout: float = ...) -> List[kevent]: ...
def fileno(self) -> int: ...
@classmethod
def fromfd(cls, fd: _FileDescriptor) -> kqueue: ...
# Linux only
class epoll(object):
if sys.version_info >= (3, 3):
def __init__(self, sizehint: int = ..., flags: int = ...) -> None: ...
else:
def __init__(self, sizehint: int = ...) -> None: ...
if sys.version_info >= (3, 4):
def __enter__(self) -> epoll: ...
def __exit__(self, *args: Any) -> None: ...
def close(self) -> None: ...
closed: bool
def fileno(self) -> int: ...
def register(self, fd: _FileDescriptor, eventmask: int = ...) -> None: ...
def modify(self, fd: _FileDescriptor, eventmask: int) -> None: ...
def unregister(self, fd: _FileDescriptor) -> None: ...
def poll(self, timeout: float = ..., maxevents: int = ...) -> List[Tuple[int, int]]: ...
@classmethod
def fromfd(cls, fd: _FileDescriptor) -> epoll: ...
if sys.version_info >= (3, 3):
# Solaris only
class devpoll:
if sys.version_info >= (3, 4):
def close(self) -> None: ...
closed: bool
def fileno(self) -> int: ...
def register(self, fd: _FileDescriptor, eventmask: int = ...) -> None: ...
def modify(self, fd: _FileDescriptor, eventmask: int = ...) -> None: ...
def unregister(self, fd: _FileDescriptor) -> None: ...
def poll(self, timeout: Optional[float] = ...) -> List[Tuple[int, int]]: ...

View File

@@ -1,27 +0,0 @@
# Stubs for select
# NOTE: These are incomplete!
from typing import Any, Tuple, List, Sequence
class error(Exception): ...
POLLIN = 0
POLLPRI = 0
POLLOUT = 0
POLLERR = 0
POLLHUP = 0
POLLNVAL = 0
class poll:
def __init__(self) -> None: ...
def register(self, fd: Any,
eventmask: int = ...) -> None: ...
def modify(self, fd: Any, eventmask: int) -> None: ...
def unregister(self, fd: Any) -> None: ...
def poll(self, timeout: int = ...) -> List[Tuple[int, int]]: ...
def select(rlist: Sequence, wlist: Sequence, xlist: Sequence,
timeout: float = ...) -> Tuple[List[Any],
List[Any],
List[Any]]: ...