@@ -23,8 +23,9 @@ from abc import abstractmethod
23
23
from builtins import OSError
24
24
from collections .abc import Callable , Iterable , Iterator , Mapping , MutableMapping , Sequence
25
25
from contextlib import AbstractContextManager
26
- from io import BufferedRandom , BufferedReader , BufferedWriter , FileIO , TextIOWrapper as _TextIOWrapper
26
+ from io import BufferedRandom , BufferedReader , BufferedWriter , FileIO , TextIOWrapper
27
27
from subprocess import Popen
28
+ from types import TracebackType
28
29
from typing import (
29
30
IO ,
30
31
Any ,
@@ -578,7 +579,7 @@ def fdopen(
578
579
newline : str | None = ...,
579
580
closefd : bool = ...,
580
581
opener : _Opener | None = ...,
581
- ) -> _TextIOWrapper : ...
582
+ ) -> TextIOWrapper : ...
582
583
@overload
583
584
def fdopen (
584
585
fd : int ,
@@ -917,9 +918,25 @@ if sys.platform != "win32":
917
918
if sys .platform != "darwin" and sys .platform != "linux" :
918
919
def plock (op : int , / ) -> None : ...
919
920
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 : ...
923
940
924
941
def popen (cmd : str , mode : str = "r" , buffering : int = - 1 ) -> _wrap_close : ...
925
942
def spawnl (mode : int , file : StrOrBytesPath , arg0 : StrOrBytesPath , * args : StrOrBytesPath ) -> int : ...
0 commit comments