@@ -110,6 +110,8 @@ __all__ = [
110110 "SupportsIndex" ,
111111 "SupportsInt" ,
112112 "SupportsRound" ,
113+ "Reader" ,
114+ "Writer" ,
113115 # One-off things.
114116 "Annotated" ,
115117 "assert_never" ,
@@ -136,6 +138,7 @@ __all__ = [
136138 "overload" ,
137139 "override" ,
138140 "Protocol" ,
141+ "Sentinel" ,
139142 "reveal_type" ,
140143 "runtime" ,
141144 "runtime_checkable" ,
@@ -199,6 +202,7 @@ _T = _TypeVar("_T")
199202_F = _TypeVar ("_F" , bound = Callable [..., Any ])
200203_TC = _TypeVar ("_TC" , bound = type [object ])
201204_T_co = _TypeVar ("_T_co" , covariant = True ) # Any type covariant containers.
205+ _T_contra = _TypeVar ("_T_contra" , contravariant = True )
202206
203207class _Final : ... # This should be imported from typing but that breaks pytype
204208
@@ -446,6 +450,19 @@ else:
446450 @abc .abstractmethod
447451 def __round__ (self , ndigits : int , / ) -> _T_co : ...
448452
453+ if sys .version_info >= (3 , 14 ):
454+ from io import Reader as Reader , Writer as Writer
455+ else :
456+ @runtime_checkable
457+ class Reader (Protocol [_T_co ]):
458+ @abc .abstractmethod
459+ def read (self , size : int = ..., / ) -> _T_co : ...
460+
461+ @runtime_checkable
462+ class Writer (Protocol [_T_contra ]):
463+ @abc .abstractmethod
464+ def write (self , data : _T_contra , / ) -> int : ...
465+
449466if sys .version_info >= (3 , 13 ):
450467 from types import CapsuleType as CapsuleType
451468 from typing import (
@@ -670,6 +687,16 @@ else:
670687 globals : Mapping [str , Any ] | None = None , # value types depend on the key
671688 locals : Mapping [str , Any ] | None = None , # value types depend on the key
672689 type_params : Iterable [TypeVar | ParamSpec | TypeVarTuple ] | None = None ,
673- format : Format = Format . VALUE , # noqa: Y011
690+ format : Format | None = None ,
674691 _recursive_guard : Container [str ] = ...,
675692 ) -> AnnotationForm : ...
693+
694+ # PEP 661
695+ class Sentinel :
696+ def __init__ (self , name : str , repr : str | None = None ) -> None : ...
697+ if sys .version_info >= (3 , 14 ):
698+ def __or__ (self , other : Any ) -> UnionType : ... # other can be any type form legal for unions
699+ def __ror__ (self , other : Any ) -> UnionType : ... # other can be any type form legal for unions
700+ else :
701+ def __or__ (self , other : Any ) -> _SpecialForm : ... # other can be any type form legal for unions
702+ def __ror__ (self , other : Any ) -> _SpecialForm : ... # other can be any type form legal for unions
0 commit comments