Add type to some asyncio.transports methods (#8756)

`WriteTransport.write`, `WriteTransport.writelines` and `DatagramTransport.sendto` methods only accept `bytes` trying an other type raises an exception

`BaseTransport._extra` is a dictionary with string as key
This commit is contained in:
François Conzelmann
2022-09-21 04:14:59 +02:00
committed by GitHub
parent 2e50b58ca9
commit 7eb277e451

View File

@@ -1,14 +1,14 @@
from asyncio.events import AbstractEventLoop
from asyncio.protocols import BaseProtocol
from collections.abc import Mapping
from collections.abc import Iterable, Mapping
from socket import _Address
from typing import Any
__all__ = ("BaseTransport", "ReadTransport", "WriteTransport", "Transport", "DatagramTransport", "SubprocessTransport")
class BaseTransport:
def __init__(self, extra: Mapping[Any, Any] | None = ...) -> None: ...
def get_extra_info(self, name: Any, default: Any = ...) -> Any: ...
def __init__(self, extra: Mapping[str, Any] | None = ...) -> None: ...
def get_extra_info(self, name: str, default: Any = ...) -> Any: ...
def is_closing(self) -> bool: ...
def close(self) -> None: ...
def set_protocol(self, protocol: BaseProtocol) -> None: ...
@@ -23,8 +23,8 @@ class WriteTransport(BaseTransport):
def set_write_buffer_limits(self, high: int | None = ..., low: int | None = ...) -> None: ...
def get_write_buffer_size(self) -> int: ...
def get_write_buffer_limits(self) -> tuple[int, int]: ...
def write(self, data: Any) -> None: ...
def writelines(self, list_of_data: list[Any]) -> None: ...
def write(self, data: bytes) -> None: ...
def writelines(self, list_of_data: Iterable[bytes]) -> None: ...
def write_eof(self) -> None: ...
def can_write_eof(self) -> bool: ...
def abort(self) -> None: ...
@@ -32,7 +32,7 @@ class WriteTransport(BaseTransport):
class Transport(ReadTransport, WriteTransport): ...
class DatagramTransport(BaseTransport):
def sendto(self, data: Any, addr: _Address | None = ...) -> None: ...
def sendto(self, data: bytes, addr: _Address | None = ...) -> None: ...
def abort(self) -> None: ...
class SubprocessTransport(BaseTransport):
@@ -44,4 +44,4 @@ class SubprocessTransport(BaseTransport):
def kill(self) -> None: ...
class _FlowControlMixin(Transport):
def __init__(self, extra: Mapping[Any, Any] | None = ..., loop: AbstractEventLoop | None = ...) -> None: ...
def __init__(self, extra: Mapping[str, Any] | None = ..., loop: AbstractEventLoop | None = ...) -> None: ...