Skip to content

Change RawIOBase return types from None to MaybeNone #12686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions stdlib/io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: ...
Expand All @@ -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
Expand Down