@@ -5,7 +5,7 @@ from _typeshed import StrPath, SupportsItems, SupportsNoArgReadline, SupportsRea
55from abc import ABCMeta , abstractmethod
66from collections .abc import Callable , Iterable , Iterator , Mapping , Sequence
77from types import GenericAlias , TracebackType
8- from typing import Any , AnyStr , Generic , Literal , Protocol , TypeVar , overload , type_check_only
8+ from typing import Any , Generic , Literal , Protocol , TypeVar , overload , type_check_only
99from typing_extensions import Self , TypeAlias
1010
1111__all__ = [
@@ -29,7 +29,6 @@ __all__ = [
2929]
3030
3131_T = TypeVar ("_T" )
32- _AnyStr = TypeVar ("_AnyStr" , str , bytes , default = bytes )
3332
3433@type_check_only
3534class _SupportsReadAndReadline (SupportsRead [bytes ], SupportsNoArgReadline [bytes ], Protocol ): ...
@@ -48,16 +47,16 @@ linesep: bytes
4847
4948# Common interface for get_file() return types.
5049@type_check_only
51- class _GetFileReturn (Protocol [ _AnyStr ] ):
52- def __iter__ (self ) -> Iterator [_AnyStr ]: ...
50+ class _GetFileReturn (Protocol ):
51+ def __iter__ (self ) -> Iterator [bytes ]: ...
5352 def __enter__ (self ) -> Self : ...
5453 def __exit__ (
5554 self , exc_type : type [BaseException ] | None , exc : BaseException | None , tb : TracebackType | None , /
5655 ) -> bool | None : ...
57- def read (self , size : int | None = None , / ) -> _AnyStr : ...
58- def read1 (self , size : int | None = None , / ) -> _AnyStr : ...
59- def readline (self , size : int | None = None , / ) -> _AnyStr : ...
60- def readlines (self , sizehint : int | None = None , / ) -> list [_AnyStr ]: ...
56+ def read (self , size : int | None = None , / ) -> bytes : ...
57+ def read1 (self , size : int | None = None , / ) -> bytes : ...
58+ def readline (self , size : int | None = None , / ) -> bytes : ...
59+ def readlines (self , sizehint : int | None = None , / ) -> list [bytes ]: ...
6160 def tell (self ) -> int : ...
6261 def seek (self , offset : int , whence : int = 0 , / ) -> object : ...
6362 def close (self ) -> object : ...
@@ -265,13 +264,14 @@ class BabylMessage(Message):
265264
266265class MMDFMessage (_mboxMMDFMessage ): ...
267266
268- class _ProxyFile (Generic [AnyStr ]):
269- def __init__ (self , f : _GetFileReturn [AnyStr ], pos : int | None = None ) -> None : ...
270- def read (self , size : int | None = None ) -> AnyStr : ...
271- def read1 (self , size : int | None = None ) -> AnyStr : ...
272- def readline (self , size : int | None = None ) -> AnyStr : ...
273- def readlines (self , sizehint : int | None = None ) -> list [AnyStr ]: ...
274- def __iter__ (self ) -> Iterator [AnyStr ]: ...
267+ # Until Python 3.14, this class was technically - but unnecessarily - generic at runtime.
268+ class _ProxyFile :
269+ def __init__ (self , f : _GetFileReturn , pos : int | None = None ) -> None : ...
270+ def read (self , size : int | None = None ) -> bytes : ...
271+ def read1 (self , size : int | None = None ) -> bytes : ...
272+ def readline (self , size : int | None = None ) -> bytes : ...
273+ def readlines (self , sizehint : int | None = None ) -> list [bytes ]: ...
274+ def __iter__ (self ) -> Iterator [bytes ]: ...
275275 def tell (self ) -> int : ...
276276 def seek (self , offset : int , whence : int = 0 ) -> None : ...
277277 def close (self ) -> None : ...
@@ -285,8 +285,8 @@ class _ProxyFile(Generic[AnyStr]):
285285 def closed (self ) -> bool : ...
286286 def __class_getitem__ (cls , item : Any , / ) -> GenericAlias : ...
287287
288- class _PartialFile (_ProxyFile [ AnyStr ] ):
289- def __init__ (self , f : _GetFileReturn [ AnyStr ] , start : int | None = None , stop : int | None = None ) -> None : ...
288+ class _PartialFile (_ProxyFile ):
289+ def __init__ (self , f : _GetFileReturn , start : int | None = None , stop : int | None = None ) -> None : ...
290290
291291class Error (Exception ): ...
292292class NoSuchMailboxError (Error ): ...
0 commit comments