-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Add public missing asyncio stubs for windows and proactor files #3234
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
061e9e9
Add public missing asyncio stubs for windows and proactor files, and …
CraftSpider ad3c45f
Add methods to BaseProactorEventLoop that mypy is complaining about, …
CraftSpider bd70a36
Add specification to Future generics
CraftSpider 16547ba
Add specification to Future generics in windows_events
CraftSpider 3e27845
Merge remote-tracking branch 'upstream/master' into asyncio-stubs
CraftSpider fe8a168
After merge, problem was obvious. Child stubs finally match parents
CraftSpider fe0fe73
Replace `pass` with `...`
CraftSpider bd78bc8
Add asyncio constants file
CraftSpider 992b556
Add Optionals, fix AbstractEventLoopPolicy -> StreamReaderProtocol, a…
CraftSpider File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
|
|
||
| import enum | ||
|
|
||
| LOG_THRESHOLD_FOR_CONNLOST_WRITES: int | ||
| ACCEPT_RETRY_DELAY: int | ||
| DEBUG_STACK_DEPTH: int | ||
| SSL_HANDSHAKE_TIMEOUT: float | ||
| SENDFILE_FALLBACK_READBUFFER_SIZE: int | ||
|
|
||
| class _SendfileMode(enum.Enum): | ||
| UNSUPPORTED: int = ... | ||
| TRY_NATIVE: int = ... | ||
| FALLBACK: int = ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
|
|
||
| from typing import Any, Mapping, Optional, Generator | ||
| from . import base_events, transports, events, streams, futures, constants | ||
| from asyncio import coroutine | ||
| from socket import socket | ||
| import sys | ||
| if sys.version_info >= (3, 8): | ||
| from typing import Literal | ||
| else: | ||
| from typing_extensions import Literal | ||
|
|
||
| class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport): | ||
|
|
||
| def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ... | ||
| def __repr__(self) -> str: ... | ||
| def __del__(self) -> None: ... | ||
| def get_write_buffer_size(self) -> int: ... | ||
|
|
||
| class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTransport): | ||
|
|
||
| def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ... | ||
|
|
||
| class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport): | ||
|
|
||
| def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ... | ||
|
|
||
| class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): | ||
|
|
||
| def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ... | ||
|
|
||
| class _ProactorDuplexPipeTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): ... | ||
|
|
||
| class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): | ||
|
|
||
| _sendfile_compatible: constants._SendfileMode = ... | ||
|
|
||
| def __init__(self, loop: events.AbstractEventLoop, sock: socket, protocol: streams.StreamReaderProtocol, waiter: Optional[futures.Future[Any]] = ..., extra: Optional[Mapping[Any, Any]] = ..., server: Optional[events.AbstractServer] = ...) -> None: ... | ||
| def _set_extra(self, sock: socket) -> None: ... | ||
| def can_write_eof(self) -> Literal[True]: ... | ||
| def write_eof(self) -> None: ... | ||
|
|
||
| class BaseProactorEventLoop(base_events.BaseEventLoop): | ||
|
|
||
| def __init__(self, proactor: Any) -> None: ... | ||
| # The methods below don't actually exist directly, ProactorEventLoops do not implement them. However, they are | ||
| # needed to satisfy mypy | ||
| if sys.version_info >= (3, 7): | ||
| async def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *, ssl: events._SSLContext = ..., | ||
| sock: Optional[socket] = ..., server_hostname: str = ..., | ||
| ssl_handshake_timeout: Optional[float] = ...) -> events._TransProtPair: ... | ||
| async def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *, sock: Optional[socket] = ..., | ||
| backlog: int = ..., ssl: events._SSLContext = ..., ssl_handshake_timeout: Optional[float] = ..., | ||
| start_serving: bool = ...) -> events.AbstractServer: ... | ||
| else: | ||
| @coroutine | ||
| def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *, | ||
| ssl: events._SSLContext = ..., sock: Optional[socket] = ..., | ||
| server_hostname: str = ...) -> Generator[Any, None, events._TransProtPair]: ... | ||
| @coroutine | ||
| def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *, | ||
| sock: Optional[socket] = ..., backlog: int = ..., ssl: events._SSLContext = ...) -> Generator[Any, None, events.AbstractServer]: ... | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
|
|
||
| from typing import Optional, Any, Generator | ||
| from . import base_events, events | ||
| from socket import socket | ||
| from asyncio import coroutine | ||
| import selectors | ||
| import sys | ||
|
|
||
| class BaseSelectorEventLoop(base_events.BaseEventLoop): | ||
|
|
||
| def __init__(self, selector: selectors.BaseSelector = ...) -> None: ... | ||
| if sys.version_info >= (3, 7): | ||
| async def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *, ssl: events._SSLContext = ..., | ||
| sock: Optional[socket] = ..., server_hostname: str = ..., | ||
| ssl_handshake_timeout: Optional[float] = ...) -> events._TransProtPair: ... | ||
| async def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *, sock: Optional[socket] = ..., | ||
| backlog: int = ..., ssl: events._SSLContext = ..., ssl_handshake_timeout: Optional[float] = ..., | ||
| start_serving: bool = ...) -> events.AbstractServer: ... | ||
| else: | ||
| @coroutine | ||
| def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *, | ||
| ssl: events._SSLContext = ..., sock: Optional[socket] = ..., | ||
| server_hostname: str = ...) -> Generator[Any, None, events._TransProtPair]: ... | ||
| @coroutine | ||
| def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *, | ||
| sock: Optional[socket] = ..., backlog: int = ..., ssl: events._SSLContext = ...) -> Generator[Any, None, events.AbstractServer]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
|
|
||
| from typing import Callable, Tuple, List, IO, Any, Optional | ||
| import socket | ||
| from . import proactor_events, events, futures, windows_utils, selector_events, streams | ||
|
|
||
| NULL: int | ||
| INFINITE: int | ||
| ERROR_CONNECTION_REFUSED: int | ||
| ERROR_CONNECTION_ABORTED: int | ||
| CONNECT_PIPE_INIT_DELAY: float | ||
| CONNECT_PIPE_MAX_DELAY: float | ||
|
|
||
| class PipeServer: | ||
|
|
||
| def __init__(self, address: str) -> None: ... | ||
| def __del__(self) -> None: ... | ||
| def closed(self) -> bool: ... | ||
| def close(self) -> None: ... | ||
|
|
||
| class _WindowsSelectorEventLoop(selector_events.BaseSelectorEventLoop): ... | ||
|
|
||
| class ProactorEventLoop(proactor_events.BaseProactorEventLoop): | ||
|
|
||
| def __init__(self, proactor: Optional[IocpProactor] = ...) -> None: ... | ||
| async def create_pipe_connection(self, protocol_factory: Callable[[], streams.StreamReaderProtocol], address: str) -> Tuple[proactor_events._ProactorDuplexPipeTransport, streams.StreamReaderProtocol]: ... | ||
| async def start_serving_pipe(self, protocol_factory: Callable[[], streams.StreamReaderProtocol], address: str) -> List[PipeServer]: ... | ||
|
|
||
| class IocpProactor: | ||
|
|
||
| def __init__(self, concurrency: int = ...) -> None: ... | ||
| def __repr__(self) -> str: ... | ||
| def __del__(self) -> None: ... | ||
| def set_loop(self, loop: events.AbstractEventLoop) -> None: ... | ||
| def select(self, timeout: Optional[int] = ...) -> List[futures.Future[Any]]: ... | ||
| def recv(self, conn: socket.socket, nbytes: int, flags: int = ...) -> futures.Future[bytes]: ... | ||
| def recv_into(self, conn: socket.socket, buf: socket._WriteBuffer, flags: int = ...) -> futures.Future[Any]: ... | ||
| def send(self, conn: socket.socket, buf: socket._WriteBuffer, flags: int = ...) -> futures.Future[Any]: ... | ||
| def accept(self, listener: socket.socket) -> futures.Future[Any]: ... | ||
| def connect(self, conn: socket.socket, address: bytes) -> futures.Future[Any]: ... | ||
| def sendfile(self, sock: socket.socket, file: IO[bytes], offset: int, count: int) -> futures.Future[Any]: ... | ||
| def accept_pipe(self, pipe: socket.socket) -> futures.Future[Any]: ... | ||
| async def connect_pipe(self, address: bytes) -> windows_utils.PipeHandle: ... | ||
| def wait_for_handle(self, handle: windows_utils.PipeHandle, timeout: int = ...) -> bool: ... | ||
| def close(self) -> None: ... | ||
|
|
||
| SelectorEventLoop = _WindowsSelectorEventLoop | ||
|
|
||
| class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): | ||
| _loop_factory: events.AbstractEventLoop = ... | ||
| def get_child_watcher(self) -> Any: ... | ||
| def set_child_watcher(self, watcher: Any) -> None: ... | ||
|
|
||
| class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): | ||
| _loop_factory: events.AbstractEventLoop = ... | ||
| def get_child_watcher(self) -> Any: ... | ||
| def set_child_watcher(self, watcher: Any) -> None: ... | ||
|
|
||
| DefaultEventLoopPolicy = WindowsSelectorEventLoopPolicy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
|
|
||
| from typing import Tuple, Callable, Optional | ||
| from types import TracebackType | ||
|
|
||
| BUFSIZE: int = ... | ||
| PIPE: int = ... | ||
| STDOUT: int = ... | ||
|
|
||
| def pipe(*, duplex: bool = ..., overlapped: Tuple[bool, bool] = ..., bufsize: int = ...) -> Tuple[int, int]: ... | ||
|
|
||
| class PipeHandle: | ||
|
|
||
| def __init__(self, handle: int) -> None: ... | ||
| def __repr__(self) -> str: ... | ||
| def __del__(self) -> None: ... | ||
| def __enter__(self) -> PipeHandle: ... | ||
| def __exit__(self, t: Optional[type], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ... | ||
| @property | ||
| def handle(self) -> int: ... | ||
| def fileno(self) -> int: ... | ||
| def close(self, *, CloseHandle: Callable[[int], None] = ...) -> None: ... |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't _ProactorSocketTransport included?