|
1 | 1 | import abc |
| 2 | +from collections.abc import Callable |
| 3 | +from socket import socket |
| 4 | +from ssl import SSLContext, SSLSocket |
| 5 | +from typing import Any |
2 | 6 |
|
3 | | -from pika.adapters.utils.nbio_interface import AbstractIOReference, AbstractStreamTransport |
| 7 | +from pika.adapters.utils.nbio_interface import ( |
| 8 | + AbstractFileDescriptorServices, |
| 9 | + AbstractIOReference, |
| 10 | + AbstractIOServices, |
| 11 | + AbstractStreamProtocol, |
| 12 | + AbstractStreamTransport, |
| 13 | +) |
| 14 | +from pika.adapters.utils.selector_ioloop_adapter import _SupportsCancel |
4 | 15 |
|
5 | | -def check_callback_arg(callback, name) -> None: ... |
6 | | -def check_fd_arg(fd) -> None: ... |
| 16 | +def check_callback_arg(callback: Callable[..., Any], name: str) -> None: ... |
| 17 | +def check_fd_arg(fd: int) -> None: ... |
7 | 18 |
|
8 | 19 | class SocketConnectionMixin: |
9 | | - def connect_socket(self, sock, resolved_addr, on_done): ... |
| 20 | + def connect_socket( |
| 21 | + self, sock: socket, resolved_addr: tuple[str, int], on_done: Callable[[BaseException | None], None] |
| 22 | + ) -> _AsyncServiceAsyncHandle: ... |
10 | 23 |
|
11 | 24 | class StreamingConnectionMixin: |
12 | | - def create_streaming_connection(self, protocol_factory, sock, on_done, ssl_context=None, server_hostname=None): ... |
| 25 | + def create_streaming_connection( |
| 26 | + self, |
| 27 | + protocol_factory: Callable[[], AbstractStreamProtocol], |
| 28 | + sock: socket, |
| 29 | + on_done: Callable[[tuple[AbstractStreamTransport, AbstractStreamProtocol] | BaseException], None], |
| 30 | + ssl_context: SSLContext | None = None, |
| 31 | + server_hostname: str | None = None, |
| 32 | + ) -> AbstractIOReference: ... |
13 | 33 |
|
14 | 34 | class _AsyncServiceAsyncHandle(AbstractIOReference): |
15 | | - def __init__(self, subject) -> None: ... |
16 | | - def cancel(self): ... |
| 35 | + def __init__(self, subject: _SupportsCancel) -> None: ... |
| 36 | + def cancel(self) -> bool: ... |
17 | 37 |
|
18 | 38 | class _AsyncSocketConnector: |
19 | | - def __init__(self, nbio, sock, resolved_addr, on_done) -> None: ... |
20 | | - def start(self): ... |
21 | | - def cancel(self): ... |
| 39 | + def __init__( |
| 40 | + self, |
| 41 | + nbio: AbstractIOServices | AbstractFileDescriptorServices, |
| 42 | + sock: socket, |
| 43 | + resolved_addr: tuple[str, int], |
| 44 | + on_done: Callable[[BaseException | None], None], |
| 45 | + ) -> None: ... |
| 46 | + def start(self) -> AbstractIOReference: ... |
| 47 | + def cancel(self) -> bool: ... |
22 | 48 |
|
23 | 49 | class _AsyncStreamConnector: |
24 | | - def __init__(self, nbio, protocol_factory, sock, ssl_context, server_hostname, on_done) -> None: ... |
25 | | - def start(self): ... |
26 | | - def cancel(self): ... |
| 50 | + def __init__( |
| 51 | + self, |
| 52 | + nbio: AbstractIOServices | AbstractFileDescriptorServices, |
| 53 | + protocol_factory: Callable[[], AbstractStreamProtocol], |
| 54 | + sock: socket, |
| 55 | + ssl_context: SSLContext, |
| 56 | + server_hostname: str | None, |
| 57 | + on_done: Callable[[tuple[AbstractStreamTransport, AbstractStreamProtocol] | BaseException], None], |
| 58 | + ) -> None: ... |
| 59 | + def start(self) -> AbstractIOReference: ... |
| 60 | + def cancel(self) -> bool: ... |
27 | 61 |
|
28 | 62 | class _AsyncTransportBase(AbstractStreamTransport, metaclass=abc.ABCMeta): |
29 | 63 | class RxEndOfFile(OSError): |
30 | 64 | def __init__(self) -> None: ... |
31 | 65 |
|
32 | | - def __init__(self, sock, protocol, nbio) -> None: ... |
| 66 | + def __init__( |
| 67 | + self, |
| 68 | + sock: socket | SSLSocket, |
| 69 | + protocol: AbstractStreamProtocol, |
| 70 | + nbio: AbstractIOServices | AbstractFileDescriptorServices, |
| 71 | + ) -> None: ... |
33 | 72 | def abort(self) -> None: ... |
34 | | - def get_protocol(self): ... |
35 | | - def get_write_buffer_size(self): ... |
| 73 | + def get_protocol(self) -> AbstractStreamProtocol: ... |
| 74 | + def get_write_buffer_size(self) -> int: ... |
36 | 75 |
|
37 | 76 | class _AsyncPlaintextTransport(_AsyncTransportBase): |
38 | | - def __init__(self, sock, protocol, nbio) -> None: ... |
39 | | - def write(self, data) -> None: ... |
| 77 | + def __init__( |
| 78 | + self, |
| 79 | + sock: socket | SSLSocket, |
| 80 | + protocol: AbstractStreamProtocol, |
| 81 | + nbio: AbstractIOServices | AbstractFileDescriptorServices, |
| 82 | + ) -> None: ... |
| 83 | + def write(self, data: bytes) -> None: ... |
40 | 84 |
|
41 | 85 | class _AsyncSSLTransport(_AsyncTransportBase): |
42 | | - def __init__(self, sock, protocol, nbio) -> None: ... |
43 | | - def write(self, data) -> None: ... |
| 86 | + def __init__( |
| 87 | + self, sock: SSLSocket, protocol: AbstractStreamProtocol, nbio: AbstractIOServices | AbstractFileDescriptorServices |
| 88 | + ) -> None: ... |
| 89 | + def write(self, data: bytes) -> None: ... |
0 commit comments