Change RawIOBase return types from None to MaybeNone (#12686)

This commit is contained in:
Sebastian Rittau
2024-10-02 16:11:23 +02:00
committed by GitHub
parent e05f3f083f
commit f266dc226a

View File

@@ -2,7 +2,7 @@ import abc
import builtins
import codecs
import sys
from _typeshed import FileDescriptorOrPath, ReadableBuffer, WriteableBuffer
from _typeshed import FileDescriptorOrPath, MaybeNone, ReadableBuffer, WriteableBuffer
from collections.abc import Callable, Iterable, Iterator
from os import _Opener
from types import TracebackType
@@ -79,9 +79,11 @@ class IOBase(metaclass=abc.ABCMeta):
class RawIOBase(IOBase):
def readall(self) -> bytes: ...
def readinto(self, buffer: WriteableBuffer, /) -> int | None: ...
def write(self, b: ReadableBuffer, /) -> int | None: ...
def read(self, size: int = -1, /) -> bytes | None: ...
# The following methods can return None if the file is in non-blocking mode
# and no data is available.
def readinto(self, buffer: WriteableBuffer, /) -> int | MaybeNone: ...
def write(self, b: ReadableBuffer, /) -> int | MaybeNone: ...
def read(self, size: int = -1, /) -> bytes | MaybeNone: ...
class BufferedIOBase(IOBase):
def detach(self) -> RawIOBase: ...
@@ -102,8 +104,6 @@ class FileIO(RawIOBase, BinaryIO): # type: ignore[misc] # incompatible definit
) -> None: ...
@property
def closefd(self) -> bool: ...
def write(self, b: ReadableBuffer, /) -> int: ...
def read(self, size: int = -1, /) -> bytes: ...
def __enter__(self) -> Self: ...
class BytesIO(BufferedIOBase, BinaryIO): # type: ignore[misc] # incompatible definitions of methods in the base classes