8000 Additional type information for asyncio by dsp · Pull Request #81 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Additional type information for asyncio #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 20, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add type information for asyncio.streams
  • Loading branch information
David Soria Parra committed Feb 20, 2016
commit bce32b0382841d3476cac2a607aaa5440ce91e4d
10 changes: 10 additions & 0 deletions stdlib/3.4/asyncio/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ from asyncio.protocols import (
DatagramProtocol as DatagramProtocol,
SubprocessProtocol as SubprocessProtocol,
)
from asyncio.streams import (
StreamReader as StreamReader,
StreamWriter as StreamWriter,
StreamReaderProtocol as StreamReaderProtocol,
open_connection as open_connection,
start_server as start_server,
IncompleteReadError as IncompleteReadError,
LimitOverrunError as LimitOverrunError,
)
from asyncio.transports import (
BaseTransport as BaseTransport,
ReadTransport as ReadTransport,
Expand Down Expand Up @@ -48,6 +57,7 @@ from asyncio.queues import (

__all__ = (coroutines.__all__ +
protocols.__all__ +
streams.__all__ +
transports.__all__ +
futures.__all__ +
tasks.__all__ +
Expand Down
104 changes: 104 additions & 0 deletions stdlib/3.4/asyncio/streams.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
from typing import Iterable, Tuple, Callable, Any, AnyStr

ClientConnectedCallback = Callable[[Tuple[StreamReader, StreamWriter]], None]
import socket

from . import coroutines
from . import events
from . import protocols
from . import transports

__all__ = ['StreamReader', 'StreamWriter', 'StreamReaderProtocol',
'open_connection', 'start_server',
'IncompleteReadError',
'LimitOverrunError']

class IncompleteReadError(EOFError):
def __init__(self, partial: str, expected: int) -> None: ...

class LimitOverrunError(Exception):
def __init__(self, message: str, consumed: int) -> None: ...

@coroutines.coroutine
def open_connection(
host: str = ...,
port: int = ...,
*,
loop: events.AbstractEventLoop = ...,
limit: int = ...,
**kwds: Any) -> Tuple[StreamReader, StreamWriter]: ...

@coroutines.coroutine
def start_server(
client_connected_cb: ClientConnectedCallback,
host: str = ...,
port: int = ...,
*,
loop: events.AbstractEventLoop = ...,
limit: int = ...,
**kwds: Any) -> events.AbstractServer: ...

if hasattr(socket, 'AF_UNIX'):
@coroutines.coroutine
def open_unix_connection(
path: str = ...,
*,
loop: events.AbstractEventLoop = ...,
limit: int = ...,
**kwds: Any): ...

@coroutines.coroutine
def start_unix_server(
client_connected_cb: ClientConnectedCallback,
path: str = ...,
*,
loop: int = ...,
limit: int = ...,
**kwds: Any) -> events.AbstractServer: ...

class FlowControlMixin(protocols.Protocol): ...

class StreamReaderProtocol(FlowControlMixin, protocols.Protocol):
def __init__(self,
stream_reader: StreamReader,
client_connected_cb: ClientConnectedCallback = ...,
loop: events.AbstractEventLoop = ...) -> None: ...
def connection_made(self, transport: transports.BaseTransport) -> None: ...
def connection_lost(self, exc: Exception) -> None: ...
def data_received(self, data: AnyStr) -> None: ...
def eof_received(self) -> bool: ...

class StreamWriter:
def __init__(self,
transport: transports.BaseTransport,
protocol: protocols.BaseProtocol,
reader: StreamReader,
loop: events.AbstractEventLoop) -> None: ...
@property
def transport(self) -> transports.BaseTransport: ...
def write(self, data: AnyStr) -> None: ...
def writelines(self, data: Iterable[str]) -> None: ...
def write_eof(self) -> None: ...
def can_write_eof(self) -> bool: ...
def close(self) -> None: ...
def get_extra_info(self, name: Any, default: Any = ...) -> Any: ...
def drain(self) -> None: ...

class StreamReader:
def __init__(self,
limit: int = ...,
loop: events.AbstractEventLoop = ...) -> None: ...
def exception(self) -> Exception: ...
def set_exception(self, exc: Exception) -> None: ...
def set_transport(self, transport: transports.BaseTransport) -> None: ...
def feed_eof(self) -> None: ...
def at_eof(self) -> bool: ...
def feed_data(self, data: AnyStr): ...
@coroutines.coroutine
def readline(self) -> str: ...
@coroutines.coroutine
def readuntil(self, separator=b'\n') -> str: ...
@coroutines.coroutine
def read(self, n=-1) -> str: ...
@coroutines.coroutine
def readexactly(self, n) -> str: ...
0