mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
[alt] typing: accept buffers in IO.write (#9861)
Co-authored-by: JelleZijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import collections # Needed by aliases like DefaultDict, see mypy issue 2986
|
||||
import sys
|
||||
import typing_extensions
|
||||
from _collections_abc import dict_items, dict_keys, dict_values
|
||||
from _typeshed import IdentityFunction, Incomplete, SupportsKeysAndGetItem
|
||||
from _typeshed import IdentityFunction, Incomplete, ReadableBuffer, SupportsKeysAndGetItem
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from contextlib import AbstractAsyncContextManager, AbstractContextManager
|
||||
from re import Match as Match, Pattern as Pattern
|
||||
@@ -687,8 +687,22 @@ class IO(Iterator[AnyStr], Generic[AnyStr]):
|
||||
@abstractmethod
|
||||
def writable(self) -> bool: ...
|
||||
@abstractmethod
|
||||
@overload
|
||||
def write(self: IO[str], __s: str) -> int: ...
|
||||
@abstractmethod
|
||||
@overload
|
||||
def write(self: IO[bytes], __s: ReadableBuffer) -> int: ...
|
||||
@abstractmethod
|
||||
@overload
|
||||
def write(self, __s: AnyStr) -> int: ...
|
||||
@abstractmethod
|
||||
@overload
|
||||
def writelines(self: IO[str], __lines: Iterable[str]) -> None: ...
|
||||
@abstractmethod
|
||||
@overload
|
||||
def writelines(self: IO[bytes], __lines: Iterable[ReadableBuffer]) -> None: ...
|
||||
@abstractmethod
|
||||
@overload
|
||||
def writelines(self, __lines: Iterable[AnyStr]) -> None: ...
|
||||
@abstractmethod
|
||||
def __next__(self) -> AnyStr: ...
|
||||
|
||||
Reference in New Issue
Block a user