Skip to content

Commit b86143c

Browse files
authored
Mark io.Reader and io.Writer as runtime-checkable (#16888)
1 parent 64af102 commit b86143c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎stdlib/io.pyi‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ from _io import (
2020
open as open,
2121
open_code as open_code,
2222
)
23-
from typing import Final, Protocol, TypeVar
23+
from typing import Final, Protocol, TypeVar, runtime_checkable
2424

2525
__all__ = [
2626
"BlockingIOError",
@@ -66,10 +66,12 @@ class BufferedIOBase(_BufferedIOBase, IOBase): ...
6666
class TextIOBase(_TextIOBase, IOBase): ...
6767

6868
if sys.version_info >= (3, 14):
69+
@runtime_checkable
6970
class Reader(Protocol[_T_co]):
7071
__slots__ = ()
7172
def read(self, size: int = ..., /) -> _T_co: ...
7273

74+
@runtime_checkable
7375
class Writer(Protocol[_T_contra]):
7476
__slots__ = ()
7577
def write(self, data: _T_contra, /) -> int: ...

0 commit comments

Comments
 (0)