@@ -23,8 +23,9 @@ from abc import abstractmethod
2323from builtins import OSError
2424from collections .abc import Callable , Iterable , Iterator , Mapping , MutableMapping , Sequence
2525from contextlib import AbstractContextManager
26- from io import BufferedRandom , BufferedReader , BufferedWriter , FileIO , TextIOWrapper as _TextIOWrapper
26+ from io import BufferedRandom , BufferedReader , BufferedWriter , FileIO , TextIOWrapper
2727from subprocess import Popen
28+ from types import TracebackType
2829from typing import (
2930 IO ,
3031 Any ,
@@ -578,7 +579,7 @@ def fdopen(
578579 newline : str | None = ...,
579580 closefd : bool = ...,
580581 opener : _Opener | None = ...,
581- ) -> _TextIOWrapper : ...
582+ ) -> TextIOWrapper : ...
582583@overload
583584def fdopen (
584585 fd : int ,
@@ -917,9 +918,25 @@ if sys.platform != "win32":
917918 if sys .platform != "darwin" and sys .platform != "linux" :
918919 def plock (op : int , / ) -> None : ...
919920
920- class _wrap_close (_TextIOWrapper ):
921- def __init__ (self , stream : _TextIOWrapper , proc : Popen [str ]) -> None : ...
922- def close (self ) -> int | None : ... # type: ignore[override]
921+ class _wrap_close :
922+ def __init__ (self , stream : TextIOWrapper , proc : Popen [str ]) -> None : ...
923+ def close (self ) -> int | None : ...
924+ def __enter__ (self ) -> Self : ...
925+ def __exit__ (
926+ self , exc_type : type [BaseException ] | None , exc_val : BaseException | None , exc_tb : TracebackType | None
927+ ) -> None : ...
928+ def __iter__ (self ) -> Iterator [str ]: ...
929+ # Methods below here don't exist directly on the _wrap_close object, but
930+ # are copied from the wrapped TextIOWrapper object via __getattr__.
931+ # The full set of TextIOWrapper methods are technically available this way,
932+ # but undocumented. Only a subset are currently included here.
933+ def read (self , size : int | None = - 1 , / ) -> str : ...
934+ def readable (self ) -> bool : ...
935+ def readline (self , size : int = - 1 , / ) -> str : ...
936+ def readlines (self , hint : int = - 1 , / ) -> list [str ]: ...
937+ def writable (self ) -> bool : ...
938+ def write (self , s : str , / ) -> int : ...
939+ def writelines (self , lines : Iterable [str ], / ) -> None : ...
923940
924941def popen (cmd : str , mode : str = "r" , buffering : int = - 1 ) -> _wrap_close : ...
925942def spawnl (mode : int , file : StrOrBytesPath , arg0 : StrOrBytesPath , * args : StrOrBytesPath ) -> int : ...
0 commit comments