1
+ import subprocess
1
2
import sys
3
+ from _typeshed import AnyPath
2
4
from asyncio import events , protocols , streams , transports
3
- from typing import IO , Any , Optional , Tuple , Union
5
+ from typing import IO , Any , Callable , Optional , Tuple , Union
6
+ from typing_extensions import Literal
4
7
5
8
if sys .version_info >= (3 , 8 ):
6
- from os import PathLike
7
-
8
- _ExecArg = Union [str , bytes , PathLike [str ], PathLike [bytes ]]
9
+ _ExecArg = AnyPath
9
10
else :
10
- _ExecArg = Union [str , bytes ] # Union used instead of AnyStr due to mypy issue #1236
11
+ _ExecArg = Union [str , bytes ]
11
12
12
13
PIPE : int
13
14
STDOUT : int
@@ -41,12 +42,30 @@ class Process:
41
42
42
43
if sys .version_info >= (3 , 10 ):
43
44
async def create_subprocess_shell (
44
- cmd : Union [str , bytes ], # Union used instead of AnyStr due to mypy issue #1236
45
+ cmd : Union [str , bytes ],
45
46
stdin : Union [int , IO [Any ], None ] = ...,
46
47
stdout : Union [int , IO [Any ], None ] = ...,
47
48
stderr : Union [int , IO [Any ], None ] = ...,
48
49
limit : int = ...,
49
- ** kwds : Any ,
50
+ * ,
51
+ # These parameters are forced to these values by BaseEventLoop.subprocess_shell
52
+ universal_newlines : Literal [False ] = ...,
53
+ shell : Literal [True ] = ...,
54
+ bufsize : Literal [0 ] = ...,
55
+ encoding : None = ...,
56
+ errors : None = ...,
57
+ text : Literal [False , None ] = ...,
58
+ # These parameters are taken by subprocess.Popen, which this ultimately delegates to
59
+ executable : Optional [AnyPath ] = ...,
60
+ preexec_fn : Optional [Callable [[], Any ]] = ...,
61
+ close_fds : bool = ...,
62
+ cwd : Optional [AnyPath ] = ...,
63
+ env : Optional [subprocess ._ENV ] = ...,
64
+ startupinfo : Optional [Any ] = ...,
65
+ creationflags : int = ...,
66
+ restore_signals : bool = ...,
67
+ start_new_session : bool = ...,
68
+ pass_fds : Any = ...,
50
69
) -> Process : ...
51
70
async def create_subprocess_exec (
52
71
program : _ExecArg ,
@@ -55,18 +74,53 @@ if sys.version_info >= (3, 10):
55
74
stdout : Union [int , IO [Any ], None ] = ...,
56
75
stderr : Union [int , IO [Any ], None ] = ...,
57
76
limit : int = ...,
58
- ** kwds : Any ,
77
+ # These parameters are forced to these values by BaseEventLoop.subprocess_shell
78
+ universal_newlines : Literal [False ] = ...,
79
+ shell : Literal [True ] = ...,
80
+ bufsize : Literal [0 ] = ...,
81
+ encoding : None = ...,
82
+ errors : None = ...,
83
+ # These parameters are taken by subprocess.Popen, which this ultimately delegates to
84
+ text : Optional [bool ] = ...,
85
+ executable : Optional [AnyPath ] = ...,
86
+ preexec_fn : Optional [Callable [[], Any ]] = ...,
87
+ close_fds : bool = ...,
88
+ cwd : Optional [AnyPath ] = ...,
89
+ env : Optional [subprocess ._ENV ] = ...,
90
+ startupinfo : Optional [Any ] = ...,
91
+ creationflags : int = ...,
92
+ restore_signals : bool = ...,
93
+ start_new_session : bool = ...,
94
+ pass_fds : Any = ...,
59
95
) -> Process : ...
60
96
61
97
else :
62
98
async def create_subprocess_shell (
63
- cmd : Union [str , bytes ], # Union used instead of AnyStr due to mypy issue #1236
99
+ cmd : Union [str , bytes ],
64
100
stdin : Union [int , IO [Any ], None ] = ...,
65
101
stdout : Union [int , IO [Any ], None ] = ...,
66
102
stderr : Union [int , IO [Any ], None ] = ...,
67
103
loop : Optional [events .AbstractEventLoop ] = ...,
68
104
limit : int = ...,
69
- ** kwds : Any ,
105
+ * ,
106
+ # These parameters are forced to these values by BaseEventLoop.subprocess_shell
107
+ universal_newlines : Literal [False ] = ...,
108
+ shell : Literal [True ] = ...,
109
+ bufsize : Literal [0 ] = ...,
110
+ encoding : None = ...,
111
+ errors : None = ...,
112
+ text : Literal [False , None ] = ...,
113
+ # These parameters are taken by subprocess.Popen, which this ultimately delegates to
114
+ executable : Optional [AnyPath ] = ...,
115
+ preexec_fn : Optional [Callable [[], Any ]] = ...,
116
+ close_fds : bool = ...,
117
+ cwd : Optional [AnyPath ] = ...,
118
+ env : Optional [subprocess ._ENV ] = ...,
119
+ startupinfo : Optional [Any ] = ...,
120
+ creationflags : int = ...,
121
+ restore_signals : bool = ...,
122
+ start_new_session : bool = ...,
123
+ pass_fds : Any = ...,
70
124
) -> Process : ...
71
125
async def create_subprocess_exec (
72
126
program : _ExecArg ,
@@ -76,5 +130,22 @@ else:
76
130
stderr : Union [int , IO [Any ], None ] = ...,
77
131
loop : Optional [events .AbstractEventLoop ] = ...,
78
132
limit : int = ...,
79
- ** kwds : Any ,
133
+ # These parameters are forced to these values by BaseEventLoop.subprocess_shell
134
+ universal_newlines : Literal [False ] = ...,
135
+ shell : Literal [True ] = ...,
136
+ bufsize : Literal [0 ] = ...,
137
+ encoding : None = ...,
138
+ errors : None = ...,
139
+ # These parameters are taken by subprocess.Popen, which this ultimately delegates to
140
+ text : Optional [bool ] = ...,
141
+ executable : Optional [AnyPath ] = ...,
142
+ preexec_fn : Optional [Callable [[], Any ]] = ...,
143
+ close_fds : bool = ...,
144
+ cwd : Optional [AnyPath ] = ...,
145
+ env : Optional [subprocess ._ENV ] = ...,
146
+ startupinfo : Optional [Any ] = ...,
147
+ creationflags : int = ...,
148
+ restore_signals : bool = ...,
149
+ start_new_session : bool = ...,
150
+ pass_fds : Any = ...,
80
151
) -> Process : ...
0 commit comments