@@ -123,7 +123,7 @@ def maybe_add_to_os_environ_pathlist(var: str, newpath: Path | str) -> None:
123
123
pass
124
124
125
125
126
- def subprocess_Popen (command : str | list [str ], ** params ):
126
+ def subprocess_Popen (command : list [str ], ** params ) -> subprocess . Popen :
127
127
"""
128
128
Utility function to work around windows behavior that open windows.
129
129
@@ -142,12 +142,12 @@ def subprocess_Popen(command: str | list[str], **params):
142
142
# in "The filename, directory name, or volume label syntax is incorrect" error message.
143
143
# Passing the command as a single string solves this problem.
144
144
if isinstance (command , list ):
145
- command = " " .join (command )
145
+ command = " " .join (command ) # type: ignore[assignment]
146
146
147
147
return subprocess .Popen (command , startupinfo = startupinfo , ** params )
148
148
149
149
150
- def call_subprocess_Popen (command , ** params ):
150
+ def call_subprocess_Popen (command : list [ str ] , ** params ) -> int :
151
151
"""
152
152
Calls subprocess_Popen and discards the output, returning only the
153
153
exit code.
@@ -165,13 +165,17 @@ def call_subprocess_Popen(command, **params):
165
165
return returncode
166
166
167
167
168
- def output_subprocess_Popen (command , ** params ):
168
+ def output_subprocess_Popen (command : list [ str ] , ** params ) -> tuple [ bytes , bytes , int ] :
169
169
"""
170
170
Calls subprocess_Popen, returning the output, error and exit code
171
171
in a tuple.
172
172
"""
173
173
if "stdout" in params or "stderr" in params :
174
174
raise TypeError ("don't use stderr or stdout with output_subprocess_Popen" )
175
+ if "encoding" in params :
176
+ raise TypeError (
177
+ "adjust the output_subprocess_Popen type annotation to support str"
178
+ )
175
179
params ["stdout" ] = subprocess .PIPE
176
180
params ["stderr" ] = subprocess .PIPE
177
181
p = subprocess_Popen (command , ** params )
0 commit comments