2
2
3
3
# Based on http://docs.python.org/2/library/subprocess.html and Python 3 stub
4
4
5
- from typing import Sequence , Any , Mapping , Callable , Tuple , IO , Union , Optional , List , Text
5
+ from typing import (
6
+ Sequence , Any , Mapping , Callable , Tuple , IO , Union , Optional , List , Text , TypeVar , Generic ,
7
+ )
8
+
9
+ # This is a dummy type variable used to make Popen generic like it is in python 3
10
+ _T = TypeVar ('_T' , bound = bytes )
6
11
7
12
_FILE = Union [None , int , IO [Any ]]
8
13
_TXT = Union [bytes , Text ]
@@ -63,17 +68,17 @@ class CalledProcessError(Exception):
63
68
# morally: _CMD
64
69
cmd : Any
65
70
# morally: Optional[bytes]
66
- output : Any
71
+ output : bytes
67
72
68
73
def __init__ (self ,
69
74
returncode : int ,
70
75
cmd : _CMD ,
71
76
output : Optional [bytes ] = ...) -> None : ...
72
77
73
- class Popen :
74
- stdin : Optional [IO [Any ]]
75
- stdout : Optional [IO [Any ]]
76
- stderr : Optional [IO [Any ]]
78
+ class Popen ( Generic [ _T ]) :
79
+ stdin : Optional [IO [bytes ]]
80
+ stdout : Optional [IO [bytes ]]
81
+ stderr : Optional [IO [bytes ]]
77
82
pid = 0
78
83
returncode = 0
79
84
@@ -96,7 +101,7 @@ class Popen:
96
101
def poll (self ) -> int : ...
97
102
def wait (self ) -> int : ...
98
103
# morally: -> Tuple[Optional[bytes], Optional[bytes]]
99
- def communicate (self , input : Optional [_TXT ] = ...) -> Tuple [Any , Any ]: ...
104
+ def communicate (self , input : Optional [_TXT ] = ...) -> Tuple [bytes , bytes ]: ...
100
105
def send_signal (self , signal : int ) -> None : ...
101
106
def terminate (self ) -> None : ...
102
107
def kill (self ) -> None : ...
0 commit comments