Skip to content
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

use a TypeVar for asyncio.BaseProtocol #478

Merged
merged 2 commits into from
Jul 16, 2022
Merged
Changes from all commits
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
38 changes: 19 additions & 19 deletions uvloop/loop.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ _T = TypeVar('_T')
_Context = Dict[str, Any]
_ExceptionHandler = Callable[[asyncio.AbstractEventLoop, _Context], Any]
_SSLContext = Union[bool, None, ssl.SSLContext]
_TransProtPair = Tuple[asyncio.transports.BaseTransport, asyncio.protocols.BaseProtocol]
_ProtocolT = TypeVar("_ProtocolT", bound=asyncio.BaseProtocol)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


class Loop:
def call_soon(
Expand Down Expand Up @@ -143,7 +143,7 @@ class Loop:
@overload
async def create_connection(
self,
protocol_factory: asyncio.events._ProtocolFactory,
protocol_factory: Callable[[], _ProtocolT],
host: str = ...,
port: int = ...,
*,
Expand All @@ -156,11 +156,11 @@ class Loop:
server_hostname: Optional[str] = ...,
ssl_handshake_timeout: Optional[float] = ...,
ssl_shutdown_timeout: Optional[float] = ...,
) -> _TransProtPair: ...
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
@overload
async def create_connection(
self,
protocol_factory: asyncio.events._ProtocolFactory,
protocol_factory: Callable[[], _ProtocolT],
host: None = ...,
port: None = ...,
*,
Expand All @@ -173,7 +173,7 @@ class Loop:
server_hostname: Optional[str] = ...,
ssl_handshake_timeout: Optional[float] = ...,
ssl_shutdown_timeout: Optional[float] = ...,
) -> _TransProtPair: ...
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
async def create_unix_server(
self,
protocol_factory: asyncio.events._ProtocolFactory,
Expand All @@ -188,15 +188,15 @@ class Loop:
) -> asyncio.AbstractServer: ...
async def create_unix_connection(
self,
protocol_factory: asyncio.events._ProtocolFactory,
protocol_factory: Callable[[], _ProtocolT],
path: Optional[str] = ...,
*,
ssl: _SSLContext = ...,
sock: Optional[socket] = ...,
server_hostname: Optional[str] = ...,
ssl_handshake_timeout: Optional[float] = ...,
ssl_shutdown_timeout: Optional[float] = ...,
) -> _TransProtPair: ...
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
def default_exception_handler(self, context: _Context) -> None: ...
def get_exception_handler(self) -> Optional[_ExceptionHandler]: ...
def set_exception_handler(self, handler: Optional[_ExceptionHandler]) -> None: ...
Expand All @@ -212,49 +212,49 @@ class Loop:
async def sock_connect(self, sock: socket, address: _Address) -> None: ...
async def connect_accepted_socket(
self,
protocol_factory: asyncio.events._ProtocolFactory,
protocol_factory: Callable[[], _ProtocolT],
sock: socket,
*,
ssl: _SSLContext = ...,
ssl_handshake_timeout: Optional[float] = ...,
ssl_shutdown_timeout: Optional[float] = ...,
) -> _TransProtPair: ...
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
async def run_in_executor(
self, executor: Any, func: Callable[..., _T], *args: Any
) -> _T: ...
def set_default_executor(self, executor: Any) -> None: ...
async def subprocess_shell(
self,
protocol_factory: asyncio.events._ProtocolFactory,
protocol_factory: Callable[[], _ProtocolT],
cmd: Union[bytes, str],
*,
stdin: Any = ...,
stdout: Any = ...,
stderr: Any = ...,
**kwargs: Any,
) -> _TransProtPair: ...
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
async def subprocess_exec(
self,
protocol_factory: asyncio.events._ProtocolFactory,
protocol_factory: Callable[[], _ProtocolT],
*args: Any,
stdin: Any = ...,
stdout: Any = ...,
stderr: Any = ...,
**kwargs: Any,
) -> _TransProtPair: ...
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
async def connect_read_pipe(
self, protocol_factory: asyncio.events._ProtocolFactory, pipe: Any
) -> _TransProtPair: ...
self, protocol_factory: Callable[[], _ProtocolT], pipe: Any
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
async def connect_write_pipe(
self, protocol_factory: asyncio.events._ProtocolFactory, pipe: Any
) -> _TransProtPair: ...
self, protocol_factory: Callable[[], _ProtocolT], pipe: Any
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
def add_signal_handler(
self, sig: int, callback: Callable[..., Any], *args: Any
) -> None: ...
def remove_signal_handler(self, sig: int) -> bool: ...
async def create_datagram_endpoint(
self,
protocol_factory: asyncio.events._ProtocolFactory,
protocol_factory: Callable[[], _ProtocolT],
local_addr: Optional[Tuple[str, int]] = ...,
remote_addr: Optional[Tuple[str, int]] = ...,
*,
Expand All @@ -265,7 +265,7 @@ class Loop:
reuse_port: Optional[bool] = ...,
allow_broadcast: Optional[bool] = ...,
sock: Optional[socket] = ...,
) -> _TransProtPair: ...
) -> tuple[asyncio.BaseProtocol, _ProtocolT]: ...
async def shutdown_asyncgens(self) -> None: ...
async def shutdown_default_executor(self) -> None: ...
# Loop doesn't implement these, but since they are marked as abstract in typeshed,
Expand Down