asyncio: improve bytes handling (#9013)

This commit is contained in:
Jelle Zijlstra
2022-10-28 15:36:44 -07:00
committed by GitHub
parent b8659e69f5
commit 583b600db0
8 changed files with 43 additions and 33 deletions

View File

@@ -3,7 +3,7 @@ import sys
from _typeshed import Self, StrPath
from collections.abc import AsyncIterator, Awaitable, Callable, Iterable, Sequence
from typing import Any
from typing_extensions import TypeAlias
from typing_extensions import SupportsIndex, TypeAlias
from . import events, protocols, transports
from .base_events import Server
@@ -139,8 +139,8 @@ class StreamWriter:
) -> None: ...
@property
def transport(self) -> transports.WriteTransport: ...
def write(self, data: bytes) -> None: ...
def writelines(self, data: Iterable[bytes]) -> None: ...
def write(self, data: bytes | bytearray | memoryview) -> None: ...
def writelines(self, data: Iterable[bytes | bytearray | memoryview]) -> None: ...
def write_eof(self) -> None: ...
def can_write_eof(self) -> bool: ...
def close(self) -> None: ...
@@ -160,9 +160,10 @@ class StreamReader(AsyncIterator[bytes]):
def set_transport(self, transport: transports.BaseTransport) -> None: ...
def feed_eof(self) -> None: ...
def at_eof(self) -> bool: ...
def feed_data(self, data: bytes) -> None: ...
def feed_data(self, data: Iterable[SupportsIndex]) -> None: ...
async def readline(self) -> bytes: ...
async def readuntil(self, separator: bytes = ...) -> bytes: ...
# Can be any buffer that supports len(); consider changing to a Protocol if PEP 688 is accepted
async def readuntil(self, separator: bytes | bytearray | memoryview = ...) -> bytes: ...
async def read(self, n: int = ...) -> bytes: ...
async def readexactly(self, n: int) -> bytes: ...
def __aiter__(self: Self) -> Self: ...