Skip to content

Commit

Permalink
use a TypeVar for asyncio.BaseProtocol (#478)
Browse files Browse the repository at this point in the history
* Revert "_TransProtPair is no longer defined in asyncio.events"

This reverts commit fae5f7f.

* fix mypy
  • Loading branch information
graingert committed Jul 16, 2022
1 parent c39afff commit 3aacb35
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions uvloop/loop.pyi
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)

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

0 comments on commit 3aacb35

Please sign in to comment.