Debian Codegraph @

jedi/third_party/typeshed/stdlib/subprocess.pyi

raw symbols SCIP
1 import sys
2 from _typeshed import MaybeNone, ReadableBuffer, StrOrBytesPath
3 from collections.abc import Callable, Collection, Iterable, Mapping, Sequence
4 from types import GenericAlias, TracebackType
5 from typing import IO, Any, AnyStr, Final, Generic, Literal, TypeVar, overload
6 from typing_extensions import Self, TypeAlias
7
8 __all__ = [
9 "Popen",
10 "PIPE",
11 "STDOUT",
12 "call",
13 "check_call",
14 "getstatusoutput",
15 "getoutput",
16 "check_output",
17 "run",
18 "CalledProcessError",
19 "DEVNULL",
20 "SubprocessError",
21 "TimeoutExpired",
22 "CompletedProcess",
23 ]
24
25 if sys.platform == "win32":
26 __all__ += [
27 "CREATE_NEW_CONSOLE",
28 "CREATE_NEW_PROCESS_GROUP",
29 "STARTF_USESHOWWINDOW",
30 "STARTF_USESTDHANDLES",
31 "STARTUPINFO",
32 "STD_ERROR_HANDLE",
33 "STD_INPUT_HANDLE",
34 "STD_OUTPUT_HANDLE",
35 "SW_HIDE",
36 "ABOVE_NORMAL_PRIORITY_CLASS",
37 "BELOW_NORMAL_PRIORITY_CLASS",
38 "CREATE_BREAKAWAY_FROM_JOB",
39 "CREATE_DEFAULT_ERROR_MODE",
40 "CREATE_NO_WINDOW",
41 "DETACHED_PROCESS",
42 "HIGH_PRIORITY_CLASS",
43 "IDLE_PRIORITY_CLASS",
44 "NORMAL_PRIORITY_CLASS",
45 "REALTIME_PRIORITY_CLASS",
46 ]
47
48 # We prefer to annotate inputs to methods (eg subprocess.check_call) with these
49 # union types.
50 # For outputs we use laborious literal based overloads to try to determine
51 # which specific return types to use, and prefer to fall back to Any when
52 # this does not work, so the caller does not have to use an assertion to confirm
53 # which type.
54 #
55 # For example:
56 #
57 # try:
58 # x = subprocess.check_output(["ls", "-l"])
59 # reveal_type(x) # bytes, based on the overloads
60 # except TimeoutError as e:
61 # reveal_type(e.cmd) # Any, but morally is _CMD
62 _FILE: TypeAlias = None | int | IO[Any]
63 _InputString: TypeAlias = ReadableBuffer | str
64 _CMD: TypeAlias = StrOrBytesPath | Sequence[StrOrBytesPath]
65 if sys.platform == "win32":
66 _ENV: TypeAlias = Mapping[str, str]
67 else:
68 _ENV: TypeAlias = Mapping[bytes, StrOrBytesPath] | Mapping[str, StrOrBytesPath]
69
70 _T = TypeVar("_T")
71
72 # These two are private but documented
73 if sys.version_info >= (3, 11):
74 _USE_VFORK: Final[bool]
75 _USE_POSIX_SPAWN: Final[bool]
76
77 class CompletedProcess(Generic[_T]):
78 # morally: _CMD
79 args: Any
80 returncode: int
81 # These can both be None, but requiring checks for None would be tedious
82 # and writing all the overloads would be horrific.
83 stdout: _T
84 stderr: _T
85 def __init__(self, args: _CMD, returncode: int, stdout: _T | None = None, stderr: _T | None = None) -> None: ...
86 def check_returncode(self) -> None: ...
87 def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
88
89 if sys.version_info >= (3, 11):
90 # 3.11 adds "process_group" argument
91 @overload
92 def run(
93 args: _CMD,
94 bufsize: int = -1,
95 executable: StrOrBytesPath | None = None,
96 stdin: _FILE = None,
97 stdout: _FILE = None,
98 stderr: _FILE = None,
99 preexec_fn: Callable[[], object] | None = None,
100 close_fds: bool = True,
101 shell: bool = False,
102 cwd: StrOrBytesPath | None = None,
103 env: _ENV | None = None,
104 universal_newlines: bool | None = None,
105 startupinfo: Any = None,
106 creationflags: int = 0,
107 restore_signals: bool = True,
108 start_new_session: bool = False,
109 pass_fds: Collection[int] = (),
110 *,
111 capture_output: bool = False,
112 check: bool = False,
113 encoding: str | None = None,
114 errors: str | None = None,
115 input: str | None = None,
116 text: Literal[True],
117 timeout: float | None = None,
118 user: str | int | None = None,
119 group: str | int | None = None,
120 extra_groups: Iterable[str | int] | None = None,
121 umask: int = -1,
122 pipesize: int = -1,
123 process_group: int | None = None,
124 ) -> CompletedProcess[str]: ...
125 @overload
126 def run(
127 args: _CMD,
128 bufsize: int = -1,
129 executable: StrOrBytesPath | None = None,
130 stdin: _FILE = None,
131 stdout: _FILE = None,
132 stderr: _FILE = None,
133 preexec_fn: Callable[[], object] | None = None,
134 close_fds: bool = True,
135 shell: bool = False,
136 cwd: StrOrBytesPath | None = None,
137 env: _ENV | None = None,
138 universal_newlines: bool | None = None,
139 startupinfo: Any = None,
140 creationflags: int = 0,
141 restore_signals: bool = True,
142 start_new_session: bool = False,
143 pass_fds: Collection[int] = (),
144 *,
145 capture_output: bool = False,
146 check: bool = False,
147 encoding: str,
148 errors: str | None = None,
149 input: str | None = None,
150 text: bool | None = None,
151 timeout: float | None = None,
152 user: str | int | None = None,
153 group: str | int | None = None,
154 extra_groups: Iterable[str | int] | None = None,
155 umask: int = -1,
156 pipesize: int = -1,
157 process_group: int | None = None,
158 ) -> CompletedProcess[str]: ...
159 @overload
160 def run(
161 args: _CMD,
162 bufsize: int = -1,
163 executable: StrOrBytesPath | None = None,
164 stdin: _FILE = None,
165 stdout: _FILE = None,
166 stderr: _FILE = None,
167 preexec_fn: Callable[[], object] | None = None,
168 close_fds: bool = True,
169 shell: bool = False,
170 cwd: StrOrBytesPath | None = None,
171 env: _ENV | None = None,
172 universal_newlines: bool | None = None,
173 startupinfo: Any = None,
174 creationflags: int = 0,
175 restore_signals: bool = True,
176 start_new_session: bool = False,
177 pass_fds: Collection[int] = (),
178 *,
179 capture_output: bool = False,
180 check: bool = False,
181 encoding: str | None = None,
182 errors: str,
183 input: str | None = None,
184 text: bool | None = None,
185 timeout: float | None = None,
186 user: str | int | None = None,
187 group: str | int | None = None,
188 extra_groups: Iterable[str | int] | None = None,
189 umask: int = -1,
190 pipesize: int = -1,
191 process_group: int | None = None,
192 ) -> CompletedProcess[str]: ...
193 @overload
194 def run(
195 args: _CMD,
196 bufsize: int = -1,
197 executable: StrOrBytesPath | None = None,
198 stdin: _FILE = None,
199 stdout: _FILE = None,
200 stderr: _FILE = None,
201 preexec_fn: Callable[[], object] | None = None,
202 close_fds: bool = True,
203 shell: bool = False,
204 cwd: StrOrBytesPath | None = None,
205 env: _ENV | None = None,
206 *,
207 universal_newlines: Literal[True],
208 startupinfo: Any = None,
209 creationflags: int = 0,
210 restore_signals: bool = True,
211 start_new_session: bool = False,
212 pass_fds: Collection[int] = (),
213 # where the *real* keyword only args start
214 capture_output: bool = False,
215 check: bool = False,
216 encoding: str | None = None,
217 errors: str | None = None,
218 input: str | None = None,
219 text: bool | None = None,
220 timeout: float | None = None,
221 user: str | int | None = None,
222 group: str | int | None = None,
223 extra_groups: Iterable[str | int] | None = None,
224 umask: int = -1,
225 pipesize: int = -1,
226 process_group: int | None = None,
227 ) -> CompletedProcess[str]: ...
228 @overload
229 def run(
230 args: _CMD,
231 bufsize: int = -1,
232 executable: StrOrBytesPath | None = None,
233 stdin: _FILE = None,
234 stdout: _FILE = None,
235 stderr: _FILE = None,
236 preexec_fn: Callable[[], object] | None = None,
237 close_fds: bool = True,
238 shell: bool = False,
239 cwd: StrOrBytesPath | None = None,
240 env: _ENV | None = None,
241 universal_newlines: Literal[False] | None = None,
242 startupinfo: Any = None,
243 creationflags: int = 0,
244 restore_signals: bool = True,
245 start_new_session: bool = False,
246 pass_fds: Collection[int] = (),
247 *,
248 capture_output: bool = False,
249 check: bool = False,
250 encoding: None = None,
251 errors: None = None,
252 input: ReadableBuffer | None = None,
253 text: Literal[False] | None = None,
254 timeout: float | None = None,
255 user: str | int | None = None,
256 group: str | int | None = None,
257 extra_groups: Iterable[str | int] | None = None,
258 umask: int = -1,
259 pipesize: int = -1,
260 process_group: int | None = None,
261 ) -> CompletedProcess[bytes]: ...
262 @overload
263 def run(
264 args: _CMD,
265 bufsize: int = -1,
266 executable: StrOrBytesPath | None = None,
267 stdin: _FILE = None,
268 stdout: _FILE = None,
269 stderr: _FILE = None,
270 preexec_fn: Callable[[], object] | None = None,
271 close_fds: bool = True,
272 shell: bool = False,
273 cwd: StrOrBytesPath | None = None,
274 env: _ENV | None = None,
275 universal_newlines: bool | None = None,
276 startupinfo: Any = None,
277 creationflags: int = 0,
278 restore_signals: bool = True,
279 start_new_session: bool = False,
280 pass_fds: Collection[int] = (),
281 *,
282 capture_output: bool = False,
283 check: bool = False,
284 encoding: str | None = None,
285 errors: str | None = None,
286 input: _InputString | None = None,
287 text: bool | None = None,
288 timeout: float | None = None,
289 user: str | int | None = None,
290 group: str | int | None = None,
291 extra_groups: Iterable[str | int] | None = None,
292 umask: int = -1,
293 pipesize: int = -1,
294 process_group: int | None = None,
295 ) -> CompletedProcess[Any]: ...
296
297 elif sys.version_info >= (3, 10):
298 # 3.10 adds "pipesize" argument
299 @overload
300 def run(
301 args: _CMD,
302 bufsize: int = -1,
303 executable: StrOrBytesPath | None = None,
304 stdin: _FILE = None,
305 stdout: _FILE = None,
306 stderr: _FILE = None,
307 preexec_fn: Callable[[], object] | None = None,
308 close_fds: bool = True,
309 shell: bool = False,
310 cwd: StrOrBytesPath | None = None,
311 env: _ENV | None = None,
312 universal_newlines: bool | None = None,
313 startupinfo: Any = None,
314 creationflags: int = 0,
315 restore_signals: bool = True,
316 start_new_session: bool = False,
317 pass_fds: Collection[int] = (),
318 *,
319 capture_output: bool = False,
320 check: bool = False,
321 encoding: str | None = None,
322 errors: str | None = None,
323 input: str | None = None,
324 text: Literal[True],
325 timeout: float | None = None,
326 user: str | int | None = None,
327 group: str | int | None = None,
328 extra_groups: Iterable[str | int] | None = None,
329 umask: int = -1,
330 pipesize: int = -1,
331 ) -> CompletedProcess[str]: ...
332 @overload
333 def run(
334 args: _CMD,
335 bufsize: int = -1,
336 executable: StrOrBytesPath | None = None,
337 stdin: _FILE = None,
338 stdout: _FILE = None,
339 stderr: _FILE = None,
340 preexec_fn: Callable[[], object] | None = None,
341 close_fds: bool = True,
342 shell: bool = False,
343 cwd: StrOrBytesPath | None = None,
344 env: _ENV | None = None,
345 universal_newlines: bool | None = None,
346 startupinfo: Any = None,
347 creationflags: int = 0,
348 restore_signals: bool = True,
349 start_new_session: bool = False,
350 pass_fds: Collection[int] = (),
351 *,
352 capture_output: bool = False,
353 check: bool = False,
354 encoding: str,
355 errors: str | None = None,
356 input: str | None = None,
357 text: bool | None = None,
358 timeout: float | None = None,
359 user: str | int | None = None,
360 group: str | int | None = None,
361 extra_groups: Iterable[str | int] | None = None,
362 umask: int = -1,
363 pipesize: int = -1,
364 ) -> CompletedProcess[str]: ...
365 @overload
366 def run(
367 args: _CMD,
368 bufsize: int = -1,
369 executable: StrOrBytesPath | None = None,
370 stdin: _FILE = None,
371 stdout: _FILE = None,
372 stderr: _FILE = None,
373 preexec_fn: Callable[[], object] | None = None,
374 close_fds: bool = True,
375 shell: bool = False,
376 cwd: StrOrBytesPath | None = None,
377 env: _ENV | None = None,
378 universal_newlines: bool | None = None,
379 startupinfo: Any = None,
380 creationflags: int = 0,
381 restore_signals: bool = True,
382 start_new_session: bool = False,
383 pass_fds: Collection[int] = (),
384 *,
385 capture_output: bool = False,
386 check: bool = False,
387 encoding: str | None = None,
388 errors: str,
389 input: str | None = None,
390 text: bool | None = None,
391 timeout: float | None = None,
392 user: str | int | None = None,
393 group: str | int | None = None,
394 extra_groups: Iterable[str | int] | None = None,
395 umask: int = -1,
396 pipesize: int = -1,
397 ) -> CompletedProcess[str]: ...
398 @overload
399 def run(
400 args: _CMD,
401 bufsize: int = -1,
402 executable: StrOrBytesPath | None = None,
403 stdin: _FILE = None,
404 stdout: _FILE = None,
405 stderr: _FILE = None,
406 preexec_fn: Callable[[], object] | None = None,
407 close_fds: bool = True,
408 shell: bool = False,
409 cwd: StrOrBytesPath | None = None,
410 env: _ENV | None = None,
411 *,
412 universal_newlines: Literal[True],
413 startupinfo: Any = None,
414 creationflags: int = 0,
415 restore_signals: bool = True,
416 start_new_session: bool = False,
417 pass_fds: Collection[int] = (),
418 # where the *real* keyword only args start
419 capture_output: bool = False,
420 check: bool = False,
421 encoding: str | None = None,
422 errors: str | None = None,
423 input: str | None = None,
424 text: bool | None = None,
425 timeout: float | None = None,
426 user: str | int | None = None,
427 group: str | int | None = None,
428 extra_groups: Iterable[str | int] | None = None,
429 umask: int = -1,
430 pipesize: int = -1,
431 ) -> CompletedProcess[str]: ...
432 @overload
433 def run(
434 args: _CMD,
435 bufsize: int = -1,
436 executable: StrOrBytesPath | None = None,
437 stdin: _FILE = None,
438 stdout: _FILE = None,
439 stderr: _FILE = None,
440 preexec_fn: Callable[[], object] | None = None,
441 close_fds: bool = True,
442 shell: bool = False,
443 cwd: StrOrBytesPath | None = None,
444 env: _ENV | None = None,
445 universal_newlines: Literal[False] | None = None,
446 startupinfo: Any = None,
447 creationflags: int = 0,
448 restore_signals: bool = True,
449 start_new_session: bool = False,
450 pass_fds: Collection[int] = (),
451 *,
452 capture_output: bool = False,
453 check: bool = False,
454 encoding: None = None,
455 errors: None = None,
456 input: ReadableBuffer | None = None,
457 text: Literal[False] | None = None,
458 timeout: float | None = None,
459 user: str | int | None = None,
460 group: str | int | None = None,
461 extra_groups: Iterable[str | int] | None = None,
462 umask: int = -1,
463 pipesize: int = -1,
464 ) -> CompletedProcess[bytes]: ...
465 @overload
466 def run(
467 args: _CMD,
468 bufsize: int = -1,
469 executable: StrOrBytesPath | None = None,
470 stdin: _FILE = None,
471 stdout: _FILE = None,
472 stderr: _FILE = None,
473 preexec_fn: Callable[[], object] | None = None,
474 close_fds: bool = True,
475 shell: bool = False,
476 cwd: StrOrBytesPath | None = None,
477 env: _ENV | None = None,
478 universal_newlines: bool | None = None,
479 startupinfo: Any = None,
480 creationflags: int = 0,
481 restore_signals: bool = True,
482 start_new_session: bool = False,
483 pass_fds: Collection[int] = (),
484 *,
485 capture_output: bool = False,
486 check: bool = False,
487 encoding: str | None = None,
488 errors: str | None = None,
489 input: _InputString | None = None,
490 text: bool | None = None,
491 timeout: float | None = None,
492 user: str | int | None = None,
493 group: str | int | None = None,
494 extra_groups: Iterable[str | int] | None = None,
495 umask: int = -1,
496 pipesize: int = -1,
497 ) -> CompletedProcess[Any]: ...
498
499 else:
500 @overload
501 def run(
502 args: _CMD,
503 bufsize: int = -1,
504 executable: StrOrBytesPath | None = None,
505 stdin: _FILE = None,
506 stdout: _FILE = None,
507 stderr: _FILE = None,
508 preexec_fn: Callable[[], object] | None = None,
509 close_fds: bool = True,
510 shell: bool = False,
511 cwd: StrOrBytesPath | None = None,
512 env: _ENV | None = None,
513 universal_newlines: bool | None = None,
514 startupinfo: Any = None,
515 creationflags: int = 0,
516 restore_signals: bool = True,
517 start_new_session: bool = False,
518 pass_fds: Collection[int] = (),
519 *,
520 capture_output: bool = False,
521 check: bool = False,
522 encoding: str | None = None,
523 errors: str | None = None,
524 input: str | None = None,
525 text: Literal[True],
526 timeout: float | None = None,
527 user: str | int | None = None,
528 group: str | int | None = None,
529 extra_groups: Iterable[str | int] | None = None,
530 umask: int = -1,
531 ) -> CompletedProcess[str]: ...
532 @overload
533 def run(
534 args: _CMD,
535 bufsize: int = -1,
536 executable: StrOrBytesPath | None = None,
537 stdin: _FILE = None,
538 stdout: _FILE = None,
539 stderr: _FILE = None,
540 preexec_fn: Callable[[], object] | None = None,
541 close_fds: bool = True,
542 shell: bool = False,
543 cwd: StrOrBytesPath | None = None,
544 env: _ENV | None = None,
545 universal_newlines: bool | None = None,
546 startupinfo: Any = None,
547 creationflags: int = 0,
548 restore_signals: bool = True,
549 start_new_session: bool = False,
550 pass_fds: Collection[int] = (),
551 *,
552 capture_output: bool = False,
553 check: bool = False,
554 encoding: str,
555 errors: str | None = None,
556 input: str | None = None,
557 text: bool | None = None,
558 timeout: float | None = None,
559 user: str | int | None = None,
560 group: str | int | None = None,
561 extra_groups: Iterable[str | int] | None = None,
562 umask: int = -1,
563 ) -> CompletedProcess[str]: ...
564 @overload
565 def run(
566 args: _CMD,
567 bufsize: int = -1,
568 executable: StrOrBytesPath | None = None,
569 stdin: _FILE = None,
570 stdout: _FILE = None,
571 stderr: _FILE = None,
572 preexec_fn: Callable[[], object] | None = None,
573 close_fds: bool = True,
574 shell: bool = False,
575 cwd: StrOrBytesPath | None = None,
576 env: _ENV | None = None,
577 universal_newlines: bool | None = None,
578 startupinfo: Any = None,
579 creationflags: int = 0,
580 restore_signals: bool = True,
581 start_new_session: bool = False,
582 pass_fds: Collection[int] = (),
583 *,
584 capture_output: bool = False,
585 check: bool = False,
586 encoding: str | None = None,
587 errors: str,
588 input: str | None = None,
589 text: bool | None = None,
590 timeout: float | None = None,
591 user: str | int | None = None,
592 group: str | int | None = None,
593 extra_groups: Iterable[str | int] | None = None,
594 umask: int = -1,
595 ) -> CompletedProcess[str]: ...
596 @overload
597 def run(
598 args: _CMD,
599 bufsize: int = -1,
600 executable: StrOrBytesPath | None = None,
601 stdin: _FILE = None,
602 stdout: _FILE = None,
603 stderr: _FILE = None,
604 preexec_fn: Callable[[], object] | None = None,
605 close_fds: bool = True,
606 shell: bool = False,
607 cwd: StrOrBytesPath | None = None,
608 env: _ENV | None = None,
609 *,
610 universal_newlines: Literal[True],
611 startupinfo: Any = None,
612 creationflags: int = 0,
613 restore_signals: bool = True,
614 start_new_session: bool = False,
615 pass_fds: Collection[int] = (),
616 # where the *real* keyword only args start
617 capture_output: bool = False,
618 check: bool = False,
619 encoding: str | None = None,
620 errors: str | None = None,
621 input: str | None = None,
622 text: bool | None = None,
623 timeout: float | None = None,
624 user: str | int | None = None,
625 group: str | int | None = None,
626 extra_groups: Iterable[str | int] | None = None,
627 umask: int = -1,
628 ) -> CompletedProcess[str]: ...
629 @overload
630 def run(
631 args: _CMD,
632 bufsize: int = -1,
633 executable: StrOrBytesPath | None = None,
634 stdin: _FILE = None,
635 stdout: _FILE = None,
636 stderr: _FILE = None,
637 preexec_fn: Callable[[], object] | None = None,
638 close_fds: bool = True,
639 shell: bool = False,
640 cwd: StrOrBytesPath | None = None,
641 env: _ENV | None = None,
642 universal_newlines: Literal[False] | None = None,
643 startupinfo: Any = None,
644 creationflags: int = 0,
645 restore_signals: bool = True,
646 start_new_session: bool = False,
647 pass_fds: Collection[int] = (),
648 *,
649 capture_output: bool = False,
650 check: bool = False,
651 encoding: None = None,
652 errors: None = None,
653 input: ReadableBuffer | None = None,
654 text: Literal[False] | None = None,
655 timeout: float | None = None,
656 user: str | int | None = None,
657 group: str | int | None = None,
658 extra_groups: Iterable[str | int] | None = None,
659 umask: int = -1,
660 ) -> CompletedProcess[bytes]: ...
661 @overload
662 def run(
663 args: _CMD,
664 bufsize: int = -1,
665 executable: StrOrBytesPath | None = None,
666 stdin: _FILE = None,
667 stdout: _FILE = None,
668 stderr: _FILE = None,
669 preexec_fn: Callable[[], object] | None = None,
670 close_fds: bool = True,
671 shell: bool = False,
672 cwd: StrOrBytesPath | None = None,
673 env: _ENV | None = None,
674 universal_newlines: bool | None = None,
675 startupinfo: Any = None,
676 creationflags: int = 0,
677 restore_signals: bool = True,
678 start_new_session: bool = False,
679 pass_fds: Collection[int] = (),
680 *,
681 capture_output: bool = False,
682 check: bool = False,
683 encoding: str | None = None,
684 errors: str | None = None,
685 input: _InputString | None = None,
686 text: bool | None = None,
687 timeout: float | None = None,
688 user: str | int | None = None,
689 group: str | int | None = None,
690 extra_groups: Iterable[str | int] | None = None,
691 umask: int = -1,
692 ) -> CompletedProcess[Any]: ...
693
694 # Same args as Popen.__init__
695 if sys.version_info >= (3, 11):
696 # 3.11 adds "process_group" argument
697 def call(
698 args: _CMD,
699 bufsize: int = -1,
700 executable: StrOrBytesPath | None = None,
701 stdin: _FILE = None,
702 stdout: _FILE = None,
703 stderr: _FILE = None,
704 preexec_fn: Callable[[], object] | None = None,
705 close_fds: bool = True,
706 shell: bool = False,
707 cwd: StrOrBytesPath | None = None,
708 env: _ENV | None = None,
709 universal_newlines: bool | None = None,
710 startupinfo: Any = None,
711 creationflags: int = 0,
712 restore_signals: bool = True,
713 start_new_session: bool = False,
714 pass_fds: Collection[int] = (),
715 *,
716 encoding: str | None = None,
717 timeout: float | None = None,
718 text: bool | None = None,
719 user: str | int | None = None,
720 group: str | int | None = None,
721 extra_groups: Iterable[str | int] | None = None,
722 umask: int = -1,
723 pipesize: int = -1,
724 process_group: int | None = None,
725 ) -> int: ...
726
727 elif sys.version_info >= (3, 10):
728 # 3.10 adds "pipesize" argument
729 def call(
730 args: _CMD,
731 bufsize: int = -1,
732 executable: StrOrBytesPath | None = None,
733 stdin: _FILE = None,
734 stdout: _FILE = None,
735 stderr: _FILE = None,
736 preexec_fn: Callable[[], object] | None = None,
737 close_fds: bool = True,
738 shell: bool = False,
739 cwd: StrOrBytesPath | None = None,
740 env: _ENV | None = None,
741 universal_newlines: bool | None = None,
742 startupinfo: Any = None,
743 creationflags: int = 0,
744 restore_signals: bool = True,
745 start_new_session: bool = False,
746 pass_fds: Collection[int] = (),
747 *,
748 encoding: str | None = None,
749 timeout: float | None = None,
750 text: bool | None = None,
751 user: str | int | None = None,
752 group: str | int | None = None,
753 extra_groups: Iterable[str | int] | None = None,
754 umask: int = -1,
755 pipesize: int = -1,
756 ) -> int: ...
757
758 else:
759 def call(
760 args: _CMD,
761 bufsize: int = -1,
762 executable: StrOrBytesPath | None = None,
763 stdin: _FILE = None,
764 stdout: _FILE = None,
765 stderr: _FILE = None,
766 preexec_fn: Callable[[], object] | None = None,
767 close_fds: bool = True,
768 shell: bool = False,
769 cwd: StrOrBytesPath | None = None,
770 env: _ENV | None = None,
771 universal_newlines: bool | None = None,
772 startupinfo: Any = None,
773 creationflags: int = 0,
774 restore_signals: bool = True,
775 start_new_session: bool = False,
776 pass_fds: Collection[int] = (),
777 *,
778 encoding: str | None = None,
779 timeout: float | None = None,
780 text: bool | None = None,
781 user: str | int | None = None,
782 group: str | int | None = None,
783 extra_groups: Iterable[str | int] | None = None,
784 umask: int = -1,
785 ) -> int: ...
786
787 # Same args as Popen.__init__
788 if sys.version_info >= (3, 11):
789 # 3.11 adds "process_group" argument
790 def check_call(
791 args: _CMD,
792 bufsize: int = -1,
793 executable: StrOrBytesPath | None = None,
794 stdin: _FILE = None,
795 stdout: _FILE = None,
796 stderr: _FILE = None,
797 preexec_fn: Callable[[], object] | None = None,
798 close_fds: bool = True,
799 shell: bool = False,
800 cwd: StrOrBytesPath | None = None,
801 env: _ENV | None = None,
802 universal_newlines: bool | None = None,
803 startupinfo: Any = None,
804 creationflags: int = 0,
805 restore_signals: bool = True,
806 start_new_session: bool = False,
807 pass_fds: Collection[int] = (),
808 timeout: float | None = None,
809 *,
810 encoding: str | None = None,
811 text: bool | None = None,
812 user: str | int | None = None,
813 group: str | int | None = None,
814 extra_groups: Iterable[str | int] | None = None,
815 umask: int = -1,
816 pipesize: int = -1,
817 process_group: int | None = None,
818 ) -> int: ...
819
820 elif sys.version_info >= (3, 10):
821 # 3.10 adds "pipesize" argument
822 def check_call(
823 args: _CMD,
824 bufsize: int = -1,
825 executable: StrOrBytesPath | None = None,
826 stdin: _FILE = None,
827 stdout: _FILE = None,
828 stderr: _FILE = None,
829 preexec_fn: Callable[[], object] | None = None,
830 close_fds: bool = True,
831 shell: bool = False,
832 cwd: StrOrBytesPath | None = None,
833 env: _ENV | None = None,
834 universal_newlines: bool | None = None,
835 startupinfo: Any = None,
836 creationflags: int = 0,
837 restore_signals: bool = True,
838 start_new_session: bool = False,
839 pass_fds: Collection[int] = (),
840 timeout: float | None = None,
841 *,
842 encoding: str | None = None,
843 text: bool | None = None,
844 user: str | int | None = None,
845 group: str | int | None = None,
846 extra_groups: Iterable[str | int] | None = None,
847 umask: int = -1,
848 pipesize: int = -1,
849 ) -> int: ...
850
851 else:
852 def check_call(
853 args: _CMD,
854 bufsize: int = -1,
855 executable: StrOrBytesPath | None = None,
856 stdin: _FILE = None,
857 stdout: _FILE = None,
858 stderr: _FILE = None,
859 preexec_fn: Callable[[], object] | None = None,
860 close_fds: bool = True,
861 shell: bool = False,
862 cwd: StrOrBytesPath | None = None,
863 env: _ENV | None = None,
864 universal_newlines: bool | None = None,
865 startupinfo: Any = None,
866 creationflags: int = 0,
867 restore_signals: bool = True,
868 start_new_session: bool = False,
869 pass_fds: Collection[int] = (),
870 timeout: float | None = None,
871 *,
872 encoding: str | None = None,
873 text: bool | None = None,
874 user: str | int | None = None,
875 group: str | int | None = None,
876 extra_groups: Iterable[str | int] | None = None,
877 umask: int = -1,
878 ) -> int: ...
879
880 if sys.version_info >= (3, 11):
881 # 3.11 adds "process_group" argument
882 @overload
883 def check_output(
884 args: _CMD,
885 bufsize: int = -1,
886 executable: StrOrBytesPath | None = None,
887 stdin: _FILE = None,
888 stderr: _FILE = None,
889 preexec_fn: Callable[[], object] | None = None,
890 close_fds: bool = True,
891 shell: bool = False,
892 cwd: StrOrBytesPath | None = None,
893 env: _ENV | None = None,
894 universal_newlines: bool | None = None,
895 startupinfo: Any = None,
896 creationflags: int = 0,
897 restore_signals: bool = True,
898 start_new_session: bool = False,
899 pass_fds: Collection[int] = (),
900 *,
901 timeout: float | None = None,
902 input: _InputString | None = None,
903 encoding: str | None = None,
904 errors: str | None = None,
905 text: Literal[True],
906 user: str | int | None = None,
907 group: str | int | None = None,
908 extra_groups: Iterable[str | int] | None = None,
909 umask: int = -1,
910 pipesize: int = -1,
911 process_group: int | None = None,
912 ) -> str: ...
913 @overload
914 def check_output(
915 args: _CMD,
916 bufsize: int = -1,
917 executable: StrOrBytesPath | None = None,
918 stdin: _FILE = None,
919 stderr: _FILE = None,
920 preexec_fn: Callable[[], object] | None = None,
921 close_fds: bool = True,
922 shell: bool = False,
923 cwd: StrOrBytesPath | None = None,
924 env: _ENV | None = None,
925 universal_newlines: bool | None = None,
926 startupinfo: Any = None,
927 creationflags: int = 0,
928 restore_signals: bool = True,
929 start_new_session: bool = False,
930 pass_fds: Collection[int] = (),
931 *,
932 timeout: float | None = None,
933 input: _InputString | None = None,
934 encoding: str,
935 errors: str | None = None,
936 text: bool | None = None,
937 user: str | int | None = None,
938 group: str | int | None = None,
939 extra_groups: Iterable[str | int] | None = None,
940 umask: int = -1,
941 pipesize: int = -1,
942 process_group: int | None = None,
943 ) -> str: ...
944 @overload
945 def check_output(
946 args: _CMD,
947 bufsize: int = -1,
948 executable: StrOrBytesPath | None = None,
949 stdin: _FILE = None,
950 stderr: _FILE = None,
951 preexec_fn: Callable[[], object] | None = None,
952 close_fds: bool = True,
953 shell: bool = False,
954 cwd: StrOrBytesPath | None = None,
955 env: _ENV | None = None,
956 universal_newlines: bool | None = None,
957 startupinfo: Any = None,
958 creationflags: int = 0,
959 restore_signals: bool = True,
960 start_new_session: bool = False,
961 pass_fds: Collection[int] = (),
962 *,
963 timeout: float | None = None,
964 input: _InputString | None = None,
965 encoding: str | None = None,
966 errors: str,
967 text: bool | None = None,
968 user: str | int | None = None,
969 group: str | int | None = None,
970 extra_groups: Iterable[str | int] | None = None,
971 umask: int = -1,
972 pipesize: int = -1,
973 process_group: int | None = None,
974 ) -> str: ...
975 @overload
976 def check_output(
977 args: _CMD,
978 bufsize: int = -1,
979 executable: StrOrBytesPath | None = None,
980 stdin: _FILE = None,
981 stderr: _FILE = None,
982 preexec_fn: Callable[[], object] | None = None,
983 close_fds: bool = True,
984 shell: bool = False,
985 cwd: StrOrBytesPath | None = None,
986 env: _ENV | None = None,
987 *,
988 universal_newlines: Literal[True],
989 startupinfo: Any = None,
990 creationflags: int = 0,
991 restore_signals: bool = True,
992 start_new_session: bool = False,
993 pass_fds: Collection[int] = (),
994 # where the real keyword only ones start
995 timeout: float | None = None,
996 input: _InputString | None = None,
997 encoding: str | None = None,
998 errors: str | None = None,
999 text: bool | None = None,
1000 user: str | int | None = None,
1001 group: str | int | None = None,
1002 extra_groups: Iterable[str | int] | None = None,
1003 umask: int = -1,
1004 pipesize: int = -1,
1005 process_group: int | None = None,
1006 ) -> str: ...
1007 @overload
1008 def check_output(
1009 args: _CMD,
1010 bufsize: int = -1,
1011 executable: StrOrBytesPath | None = None,
1012 stdin: _FILE = None,
1013 stderr: _FILE = None,
1014 preexec_fn: Callable[[], object] | None = None,
1015 close_fds: bool = True,
1016 shell: bool = False,
1017 cwd: StrOrBytesPath | None = None,
1018 env: _ENV | None = None,
1019 universal_newlines: Literal[False] | None = None,
1020 startupinfo: Any = None,
1021 creationflags: int = 0,
1022 restore_signals: bool = True,
1023 start_new_session: bool = False,
1024 pass_fds: Collection[int] = (),
1025 *,
1026 timeout: float | None = None,
1027 input: _InputString | None = None,
1028 encoding: None = None,
1029 errors: None = None,
1030 text: Literal[False] | None = None,
1031 user: str | int | None = None,
1032 group: str | int | None = None,
1033 extra_groups: Iterable[str | int] | None = None,
1034 umask: int = -1,
1035 pipesize: int = -1,
1036 process_group: int | None = None,
1037 ) -> bytes: ...
1038 @overload
1039 def check_output(
1040 args: _CMD,
1041 bufsize: int = -1,
1042 executable: StrOrBytesPath | None = None,
1043 stdin: _FILE = None,
1044 stderr: _FILE = None,
1045 preexec_fn: Callable[[], object] | None = None,
1046 close_fds: bool = True,
1047 shell: bool = False,
1048 cwd: StrOrBytesPath | None = None,
1049 env: _ENV | None = None,
1050 universal_newlines: bool | None = None,
1051 startupinfo: Any = None,
1052 creationflags: int = 0,
1053 restore_signals: bool = True,
1054 start_new_session: bool = False,
1055 pass_fds: Collection[int] = (),
1056 *,
1057 timeout: float | None = None,
1058 input: _InputString | None = None,
1059 encoding: str | None = None,
1060 errors: str | None = None,
1061 text: bool | None = None,
1062 user: str | int | None = None,
1063 group: str | int | None = None,
1064 extra_groups: Iterable[str | int] | None = None,
1065 umask: int = -1,
1066 pipesize: int = -1,
1067 process_group: int | None = None,
1068 ) -> Any: ... # morally: -> str | bytes
1069
1070 elif sys.version_info >= (3, 10):
1071 # 3.10 adds "pipesize" argument
1072 @overload
1073 def check_output(
1074 args: _CMD,
1075 bufsize: int = -1,
1076 executable: StrOrBytesPath | None = None,
1077 stdin: _FILE = None,
1078 stderr: _FILE = None,
1079 preexec_fn: Callable[[], object] | None = None,
1080 close_fds: bool = True,
1081 shell: bool = False,
1082 cwd: StrOrBytesPath | None = None,
1083 env: _ENV | None = None,
1084 universal_newlines: bool | None = None,
1085 startupinfo: Any = None,
1086 creationflags: int = 0,
1087 restore_signals: bool = True,
1088 start_new_session: bool = False,
1089 pass_fds: Collection[int] = (),
1090 *,
1091 timeout: float | None = None,
1092 input: _InputString | None = None,
1093 encoding: str | None = None,
1094 errors: str | None = None,
1095 text: Literal[True],
1096 user: str | int | None = None,
1097 group: str | int | None = None,
1098 extra_groups: Iterable[str | int] | None = None,
1099 umask: int = -1,
1100 pipesize: int = -1,
1101 ) -> str: ...
1102 @overload
1103 def check_output(
1104 args: _CMD,
1105 bufsize: int = -1,
1106 executable: StrOrBytesPath | None = None,
1107 stdin: _FILE = None,
1108 stderr: _FILE = None,
1109 preexec_fn: Callable[[], object] | None = None,
1110 close_fds: bool = True,
1111 shell: bool = False,
1112 cwd: StrOrBytesPath | None = None,
1113 env: _ENV | None = None,
1114 universal_newlines: bool | None = None,
1115 startupinfo: Any = None,
1116 creationflags: int = 0,
1117 restore_signals: bool = True,
1118 start_new_session: bool = False,
1119 pass_fds: Collection[int] = (),
1120 *,
1121 timeout: float | None = None,
1122 input: _InputString | None = None,
1123 encoding: str,
1124 errors: str | None = None,
1125 text: bool | None = None,
1126 user: str | int | None = None,
1127 group: str | int | None = None,
1128 extra_groups: Iterable[str | int] | None = None,
1129 umask: int = -1,
1130 pipesize: int = -1,
1131 ) -> str: ...
1132 @overload
1133 def check_output(
1134 args: _CMD,
1135 bufsize: int = -1,
1136 executable: StrOrBytesPath | None = None,
1137 stdin: _FILE = None,
1138 stderr: _FILE = None,
1139 preexec_fn: Callable[[], object] | None = None,
1140 close_fds: bool = True,
1141 shell: bool = False,
1142 cwd: StrOrBytesPath | None = None,
1143 env: _ENV | None = None,
1144 universal_newlines: bool | None = None,
1145 startupinfo: Any = None,
1146 creationflags: int = 0,
1147 restore_signals: bool = True,
1148 start_new_session: bool = False,
1149 pass_fds: Collection[int] = (),
1150 *,
1151 timeout: float | None = None,
1152 input: _InputString | None = None,
1153 encoding: str | None = None,
1154 errors: str,
1155 text: bool | None = None,
1156 user: str | int | None = None,
1157 group: str | int | None = None,
1158 extra_groups: Iterable[str | int] | None = None,
1159 umask: int = -1,
1160 pipesize: int = -1,
1161 ) -> str: ...
1162 @overload
1163 def check_output(
1164 args: _CMD,
1165 bufsize: int = -1,
1166 executable: StrOrBytesPath | None = None,
1167 stdin: _FILE = None,
1168 stderr: _FILE = None,
1169 preexec_fn: Callable[[], object] | None = None,
1170 close_fds: bool = True,
1171 shell: bool = False,
1172 cwd: StrOrBytesPath | None = None,
1173 env: _ENV | None = None,
1174 *,
1175 universal_newlines: Literal[True],
1176 startupinfo: Any = None,
1177 creationflags: int = 0,
1178 restore_signals: bool = True,
1179 start_new_session: bool = False,
1180 pass_fds: Collection[int] = (),
1181 # where the real keyword only ones start
1182 timeout: float | None = None,
1183 input: _InputString | None = None,
1184 encoding: str | None = None,
1185 errors: str | None = None,
1186 text: bool | None = None,
1187 user: str | int | None = None,
1188 group: str | int | None = None,
1189 extra_groups: Iterable[str | int] | None = None,
1190 umask: int = -1,
1191 pipesize: int = -1,
1192 ) -> str: ...
1193 @overload
1194 def check_output(
1195 args: _CMD,
1196 bufsize: int = -1,
1197 executable: StrOrBytesPath | None = None,
1198 stdin: _FILE = None,
1199 stderr: _FILE = None,
1200 preexec_fn: Callable[[], object] | None = None,
1201 close_fds: bool = True,
1202 shell: bool = False,
1203 cwd: StrOrBytesPath | None = None,
1204 env: _ENV | None = None,
1205 universal_newlines: Literal[False] | None = None,
1206 startupinfo: Any = None,
1207 creationflags: int = 0,
1208 restore_signals: bool = True,
1209 start_new_session: bool = False,
1210 pass_fds: Collection[int] = (),
1211 *,
1212 timeout: float | None = None,
1213 input: _InputString | None = None,
1214 encoding: None = None,
1215 errors: None = None,
1216 text: Literal[False] | None = None,
1217 user: str | int | None = None,
1218 group: str | int | None = None,
1219 extra_groups: Iterable[str | int] | None = None,
1220 umask: int = -1,
1221 pipesize: int = -1,
1222 ) -> bytes: ...
1223 @overload
1224 def check_output(
1225 args: _CMD,
1226 bufsize: int = -1,
1227 executable: StrOrBytesPath | None = None,
1228 stdin: _FILE = None,
1229 stderr: _FILE = None,
1230 preexec_fn: Callable[[], object] | None = None,
1231 close_fds: bool = True,
1232 shell: bool = False,
1233 cwd: StrOrBytesPath | None = None,
1234 env: _ENV | None = None,
1235 universal_newlines: bool | None = None,
1236 startupinfo: Any = None,
1237 creationflags: int = 0,
1238 restore_signals: bool = True,
1239 start_new_session: bool = False,
1240 pass_fds: Collection[int] = (),
1241 *,
1242 timeout: float | None = None,
1243 input: _InputString | None = None,
1244 encoding: str | None = None,
1245 errors: str | None = None,
1246 text: bool | None = None,
1247 user: str | int | None = None,
1248 group: str | int | None = None,
1249 extra_groups: Iterable[str | int] | None = None,
1250 umask: int = -1,
1251 pipesize: int = -1,
1252 ) -> Any: ... # morally: -> str | bytes
1253
1254 else:
1255 @overload
1256 def check_output(
1257 args: _CMD,
1258 bufsize: int = -1,
1259 executable: StrOrBytesPath | None = None,
1260 stdin: _FILE = None,
1261 stderr: _FILE = None,
1262 preexec_fn: Callable[[], object] | None = None,
1263 close_fds: bool = True,
1264 shell: bool = False,
1265 cwd: StrOrBytesPath | None = None,
1266 env: _ENV | None = None,
1267 universal_newlines: bool | None = None,
1268 startupinfo: Any = None,
1269 creationflags: int = 0,
1270 restore_signals: bool = True,
1271 start_new_session: bool = False,
1272 pass_fds: Collection[int] = (),
1273 *,
1274 timeout: float | None = None,
1275 input: _InputString | None = None,
1276 encoding: str | None = None,
1277 errors: str | None = None,
1278 text: Literal[True],
1279 user: str | int | None = None,
1280 group: str | int | None = None,
1281 extra_groups: Iterable[str | int] | None = None,
1282 umask: int = -1,
1283 ) -> str: ...
1284 @overload
1285 def check_output(
1286 args: _CMD,
1287 bufsize: int = -1,
1288 executable: StrOrBytesPath | None = None,
1289 stdin: _FILE = None,
1290 stderr: _FILE = None,
1291 preexec_fn: Callable[[], object] | None = None,
1292 close_fds: bool = True,
1293 shell: bool = False,
1294 cwd: StrOrBytesPath | None = None,
1295 env: _ENV | None = None,
1296 universal_newlines: bool | None = None,
1297 startupinfo: Any = None,
1298 creationflags: int = 0,
1299 restore_signals: bool = True,
1300 start_new_session: bool = False,
1301 pass_fds: Collection[int] = (),
1302 *,
1303 timeout: float | None = None,
1304 input: _InputString | None = None,
1305 encoding: str,
1306 errors: str | None = None,
1307 text: bool | None = None,
1308 user: str | int | None = None,
1309 group: str | int | None = None,
1310 extra_groups: Iterable[str | int] | None = None,
1311 umask: int = -1,
1312 ) -> str: ...
1313 @overload
1314 def check_output(
1315 args: _CMD,
1316 bufsize: int = -1,
1317 executable: StrOrBytesPath | None = None,
1318 stdin: _FILE = None,
1319 stderr: _FILE = None,
1320 preexec_fn: Callable[[], object] | None = None,
1321 close_fds: bool = True,
1322 shell: bool = False,
1323 cwd: StrOrBytesPath | None = None,
1324 env: _ENV | None = None,
1325 universal_newlines: bool | None = None,
1326 startupinfo: Any = None,
1327 creationflags: int = 0,
1328 restore_signals: bool = True,
1329 start_new_session: bool = False,
1330 pass_fds: Collection[int] = (),
1331 *,
1332 timeout: float | None = None,
1333 input: _InputString | None = None,
1334 encoding: str | None = None,
1335 errors: str,
1336 text: bool | None = None,
1337 user: str | int | None = None,
1338 group: str | int | None = None,
1339 extra_groups: Iterable[str | int] | None = None,
1340 umask: int = -1,
1341 ) -> str: ...
1342 @overload
1343 def check_output(
1344 args: _CMD,
1345 bufsize: int = -1,
1346 executable: StrOrBytesPath | None = None,
1347 stdin: _FILE = None,
1348 stderr: _FILE = None,
1349 preexec_fn: Callable[[], object] | None = None,
1350 close_fds: bool = True,
1351 shell: bool = False,
1352 cwd: StrOrBytesPath | None = None,
1353 env: _ENV | None = None,
1354 *,
1355 universal_newlines: Literal[True],
1356 startupinfo: Any = None,
1357 creationflags: int = 0,
1358 restore_signals: bool = True,
1359 start_new_session: bool = False,
1360 pass_fds: Collection[int] = (),
1361 # where the real keyword only ones start
1362 timeout: float | None = None,
1363 input: _InputString | None = None,
1364 encoding: str | None = None,
1365 errors: str | None = None,
1366 text: bool | None = None,
1367 user: str | int | None = None,
1368 group: str | int | None = None,
1369 extra_groups: Iterable[str | int] | None = None,
1370 umask: int = -1,
1371 ) -> str: ...
1372 @overload
1373 def check_output(
1374 args: _CMD,
1375 bufsize: int = -1,
1376 executable: StrOrBytesPath | None = None,
1377 stdin: _FILE = None,
1378 stderr: _FILE = None,
1379 preexec_fn: Callable[[], object] | None = None,
1380 close_fds: bool = True,
1381 shell: bool = False,
1382 cwd: StrOrBytesPath | None = None,
1383 env: _ENV | None = None,
1384 universal_newlines: Literal[False] | None = None,
1385 startupinfo: Any = None,
1386 creationflags: int = 0,
1387 restore_signals: bool = True,
1388 start_new_session: bool = False,
1389 pass_fds: Collection[int] = (),
1390 *,
1391 timeout: float | None = None,
1392 input: _InputString | None = None,
1393 encoding: None = None,
1394 errors: None = None,
1395 text: Literal[False] | None = None,
1396 user: str | int | None = None,
1397 group: str | int | None = None,
1398 extra_groups: Iterable[str | int] | None = None,
1399 umask: int = -1,
1400 ) -> bytes: ...
1401 @overload
1402 def check_output(
1403 args: _CMD,
1404 bufsize: int = -1,
1405 executable: StrOrBytesPath | None = None,
1406 stdin: _FILE = None,
1407 stderr: _FILE = None,
1408 preexec_fn: Callable[[], object] | None = None,
1409 close_fds: bool = True,
1410 shell: bool = False,
1411 cwd: StrOrBytesPath | None = None,
1412 env: _ENV | None = None,
1413 universal_newlines: bool | None = None,
1414 startupinfo: Any = None,
1415 creationflags: int = 0,
1416 restore_signals: bool = True,
1417 start_new_session: bool = False,
1418 pass_fds: Collection[int] = (),
1419 *,
1420 timeout: float | None = None,
1421 input: _InputString | None = None,
1422 encoding: str | None = None,
1423 errors: str | None = None,
1424 text: bool | None = None,
1425 user: str | int | None = None,
1426 group: str | int | None = None,
1427 extra_groups: Iterable[str | int] | None = None,
1428 umask: int = -1,
1429 ) -> Any: ... # morally: -> str | bytes
1430
1431 PIPE: Final[int]
1432 STDOUT: Final[int]
1433 DEVNULL: Final[int]
1434
1435 class SubprocessError(Exception): ...
1436
1437 class TimeoutExpired(SubprocessError):
1438 def __init__(
1439 self, cmd: _CMD, timeout: float, output: str | bytes | None = None, stderr: str | bytes | None = None
1440 ) -> None: ...
1441 # morally: _CMD
1442 cmd: Any
1443 timeout: float
1444 # morally: str | bytes | None
1445 output: Any
1446 stdout: bytes | None
1447 stderr: bytes | None
1448
1449 class CalledProcessError(SubprocessError):
1450 returncode: int
1451 # morally: _CMD
1452 cmd: Any
1453 # morally: str | bytes | None
1454 output: Any
1455
1456 # morally: str | bytes | None
1457 stdout: Any
1458 stderr: Any
1459 def __init__(
1460 self, returncode: int, cmd: _CMD, output: str | bytes | None = None, stderr: str | bytes | None = None
1461 ) -> None: ...
1462
1463 class Popen(Generic[AnyStr]):
1464 args: _CMD
1465 stdin: IO[AnyStr] | None
1466 stdout: IO[AnyStr] | None
1467 stderr: IO[AnyStr] | None
1468 pid: int
1469 returncode: int | MaybeNone
1470 universal_newlines: bool
1471
1472 if sys.version_info >= (3, 11):
1473 # process_group is added in 3.11
1474 @overload
1475 def __init__(
1476 self: Popen[str],
1477 args: _CMD,
1478 bufsize: int = -1,
1479 executable: StrOrBytesPath | None = None,
1480 stdin: _FILE | None = None,
1481 stdout: _FILE | None = None,
1482 stderr: _FILE | None = None,
1483 preexec_fn: Callable[[], object] | None = None,
1484 close_fds: bool = True,
1485 shell: bool = False,
1486 cwd: StrOrBytesPath | None = None,
1487 env: _ENV | None = None,
1488 universal_newlines: bool | None = None,
1489 startupinfo: Any | None = None,
1490 creationflags: int = 0,
1491 restore_signals: bool = True,
1492 start_new_session: bool = False,
1493 pass_fds: Collection[int] = (),
1494 *,
1495 text: bool | None = None,
1496 encoding: str,
1497 errors: str | None = None,
1498 user: str | int | None = None,
1499 group: str | int | None = None,
1500 extra_groups: Iterable[str | int] | None = None,
1501 umask: int = -1,
1502 pipesize: int = -1,
1503 process_group: int | None = None,
1504 ) -> None: ...
1505 @overload
1506 def __init__(
1507 self: Popen[str],
1508 args: _CMD,
1509 bufsize: int = -1,
1510 executable: StrOrBytesPath | None = None,
1511 stdin: _FILE | None = None,
1512 stdout: _FILE | None = None,
1513 stderr: _FILE | None = None,
1514 preexec_fn: Callable[[], object] | None = None,
1515 close_fds: bool = True,
1516 shell: bool = False,
1517 cwd: StrOrBytesPath | None = None,
1518 env: _ENV | None = None,
1519 universal_newlines: bool | None = None,
1520 startupinfo: Any | None = None,
1521 creationflags: int = 0,
1522 restore_signals: bool = True,
1523 start_new_session: bool = False,
1524 pass_fds: Collection[int] = (),
1525 *,
1526 text: bool | None = None,
1527 encoding: str | None = None,
1528 errors: str,
1529 user: str | int | None = None,
1530 group: str | int | None = None,
1531 extra_groups: Iterable[str | int] | None = None,
1532 umask: int = -1,
1533 pipesize: int = -1,
1534 process_group: int | None = None,
1535 ) -> None: ...
1536 @overload
1537 def __init__(
1538 self: Popen[str],
1539 args: _CMD,
1540 bufsize: int = -1,
1541 executable: StrOrBytesPath | None = None,
1542 stdin: _FILE | None = None,
1543 stdout: _FILE | None = None,
1544 stderr: _FILE | None = None,
1545 preexec_fn: Callable[[], object] | None = None,
1546 close_fds: bool = True,
1547 shell: bool = False,
1548 cwd: StrOrBytesPath | None = None,
1549 env: _ENV | None = None,
1550 *,
1551 universal_newlines: Literal[True],
1552 startupinfo: Any | None = None,
1553 creationflags: int = 0,
1554 restore_signals: bool = True,
1555 start_new_session: bool = False,
1556 pass_fds: Collection[int] = (),
1557 # where the *real* keyword only args start
1558 text: bool | None = None,
1559 encoding: str | None = None,
1560 errors: str | None = None,
1561 user: str | int | None = None,
1562 group: str | int | None = None,
1563 extra_groups: Iterable[str | int] | None = None,
1564 umask: int = -1,
1565 pipesize: int = -1,
1566 process_group: int | None = None,
1567 ) -> None: ...
1568 @overload
1569 def __init__(
1570 self: Popen[str],
1571 args: _CMD,
1572 bufsize: int = -1,
1573 executable: StrOrBytesPath | None = None,
1574 stdin: _FILE | None = None,
1575 stdout: _FILE | None = None,
1576 stderr: _FILE | None = None,
1577 preexec_fn: Callable[[], object] | None = None,
1578 close_fds: bool = True,
1579 shell: bool = False,
1580 cwd: StrOrBytesPath | None = None,
1581 env: _ENV | None = None,
1582 universal_newlines: bool | None = None,
1583 startupinfo: Any | None = None,
1584 creationflags: int = 0,
1585 restore_signals: bool = True,
1586 start_new_session: bool = False,
1587 pass_fds: Collection[int] = (),
1588 *,
1589 text: Literal[True],
1590 encoding: str | None = None,
1591 errors: str | None = None,
1592 user: str | int | None = None,
1593 group: str | int | None = None,
1594 extra_groups: Iterable[str | int] | None = None,
1595 umask: int = -1,
1596 pipesize: int = -1,
1597 process_group: int | None = None,
1598 ) -> None: ...
1599 @overload
1600 def __init__(
1601 self: Popen[bytes],
1602 args: _CMD,
1603 bufsize: int = -1,
1604 executable: StrOrBytesPath | None = None,
1605 stdin: _FILE | None = None,
1606 stdout: _FILE | None = None,
1607 stderr: _FILE | None = None,
1608 preexec_fn: Callable[[], object] | None = None,
1609 close_fds: bool = True,
1610 shell: bool = False,
1611 cwd: StrOrBytesPath | None = None,
1612 env: _ENV | None = None,
1613 universal_newlines: Literal[False] | None = None,
1614 startupinfo: Any | None = None,
1615 creationflags: int = 0,
1616 restore_signals: bool = True,
1617 start_new_session: bool = False,
1618 pass_fds: Collection[int] = (),
1619 *,
1620 text: Literal[False] | None = None,
1621 encoding: None = None,
1622 errors: None = None,
1623 user: str | int | None = None,
1624 group: str | int | None = None,
1625 extra_groups: Iterable[str | int] | None = None,
1626 umask: int = -1,
1627 pipesize: int = -1,
1628 process_group: int | None = None,
1629 ) -> None: ...
1630 @overload
1631 def __init__(
1632 self: Popen[Any],
1633 args: _CMD,
1634 bufsize: int = -1,
1635 executable: StrOrBytesPath | None = None,
1636 stdin: _FILE | None = None,
1637 stdout: _FILE | None = None,
1638 stderr: _FILE | None = None,
1639 preexec_fn: Callable[[], object] | None = None,
1640 close_fds: bool = True,
1641 shell: bool = False,
1642 cwd: StrOrBytesPath | None = None,
1643 env: _ENV | None = None,
1644 universal_newlines: bool | None = None,
1645 startupinfo: Any | None = None,
1646 creationflags: int = 0,
1647 restore_signals: bool = True,
1648 start_new_session: bool = False,
1649 pass_fds: Collection[int] = (),
1650 *,
1651 text: bool | None = None,
1652 encoding: str | None = None,
1653 errors: str | None = None,
1654 user: str | int | None = None,
1655 group: str | int | None = None,
1656 extra_groups: Iterable[str | int] | None = None,
1657 umask: int = -1,
1658 pipesize: int = -1,
1659 process_group: int | None = None,
1660 ) -> None: ...
1661 elif sys.version_info >= (3, 10):
1662 # pipesize is added in 3.10
1663 @overload
1664 def __init__(
1665 self: Popen[str],
1666 args: _CMD,
1667 bufsize: int = -1,
1668 executable: StrOrBytesPath | None = None,
1669 stdin: _FILE | None = None,
1670 stdout: _FILE | None = None,
1671 stderr: _FILE | None = None,
1672 preexec_fn: Callable[[], object] | None = None,
1673 close_fds: bool = True,
1674 shell: bool = False,
1675 cwd: StrOrBytesPath | None = None,
1676 env: _ENV | None = None,
1677 universal_newlines: bool | None = None,
1678 startupinfo: Any | None = None,
1679 creationflags: int = 0,
1680 restore_signals: bool = True,
1681 start_new_session: bool = False,
1682 pass_fds: Collection[int] = (),
1683 *,
1684 text: bool | None = None,
1685 encoding: str,
1686 errors: str | None = None,
1687 user: str | int | None = None,
1688 group: str | int | None = None,
1689 extra_groups: Iterable[str | int] | None = None,
1690 umask: int = -1,
1691 pipesize: int = -1,
1692 ) -> None: ...
1693 @overload
1694 def __init__(
1695 self: Popen[str],
1696 args: _CMD,
1697 bufsize: int = -1,
1698 executable: StrOrBytesPath | None = None,
1699 stdin: _FILE | None = None,
1700 stdout: _FILE | None = None,
1701 stderr: _FILE | None = None,
1702 preexec_fn: Callable[[], object] | None = None,
1703 close_fds: bool = True,
1704 shell: bool = False,
1705 cwd: StrOrBytesPath | None = None,
1706 env: _ENV | None = None,
1707 universal_newlines: bool | None = None,
1708 startupinfo: Any | None = None,
1709 creationflags: int = 0,
1710 restore_signals: bool = True,
1711 start_new_session: bool = False,
1712 pass_fds: Collection[int] = (),
1713 *,
1714 text: bool | None = None,
1715 encoding: str | None = None,
1716 errors: str,
1717 user: str | int | None = None,
1718 group: str | int | None = None,
1719 extra_groups: Iterable[str | int] | None = None,
1720 umask: int = -1,
1721 pipesize: int = -1,
1722 ) -> None: ...
1723 @overload
1724 def __init__(
1725 self: Popen[str],
1726 args: _CMD,
1727 bufsize: int = -1,
1728 executable: StrOrBytesPath | None = None,
1729 stdin: _FILE | None = None,
1730 stdout: _FILE | None = None,
1731 stderr: _FILE | None = None,
1732 preexec_fn: Callable[[], object] | None = None,
1733 close_fds: bool = True,
1734 shell: bool = False,
1735 cwd: StrOrBytesPath | None = None,
1736 env: _ENV | None = None,
1737 *,
1738 universal_newlines: Literal[True],
1739 startupinfo: Any | None = None,
1740 creationflags: int = 0,
1741 restore_signals: bool = True,
1742 start_new_session: bool = False,
1743 pass_fds: Collection[int] = (),
1744 # where the *real* keyword only args start
1745 text: bool | None = None,
1746 encoding: str | None = None,
1747 errors: str | None = None,
1748 user: str | int | None = None,
1749 group: str | int | None = None,
1750 extra_groups: Iterable[str | int] | None = None,
1751 umask: int = -1,
1752 pipesize: int = -1,
1753 ) -> None: ...
1754 @overload
1755 def __init__(
1756 self: Popen[str],
1757 args: _CMD,
1758 bufsize: int = -1,
1759 executable: StrOrBytesPath | None = None,
1760 stdin: _FILE | None = None,
1761 stdout: _FILE | None = None,
1762 stderr: _FILE | None = None,
1763 preexec_fn: Callable[[], object] | None = None,
1764 close_fds: bool = True,
1765 shell: bool = False,
1766 cwd: StrOrBytesPath | None = None,
1767 env: _ENV | None = None,
1768 universal_newlines: bool | None = None,
1769 startupinfo: Any | None = None,
1770 creationflags: int = 0,
1771 restore_signals: bool = True,
1772 start_new_session: bool = False,
1773 pass_fds: Collection[int] = (),
1774 *,
1775 text: Literal[True],
1776 encoding: str | None = None,
1777 errors: str | None = None,
1778 user: str | int | None = None,
1779 group: str | int | None = None,
1780 extra_groups: Iterable[str | int] | None = None,
1781 umask: int = -1,
1782 pipesize: int = -1,
1783 ) -> None: ...
1784 @overload
1785 def __init__(
1786 self: Popen[bytes],
1787 args: _CMD,
1788 bufsize: int = -1,
1789 executable: StrOrBytesPath | None = None,
1790 stdin: _FILE | None = None,
1791 stdout: _FILE | None = None,
1792 stderr: _FILE | None = None,
1793 preexec_fn: Callable[[], object] | None = None,
1794 close_fds: bool = True,
1795 shell: bool = False,
1796 cwd: StrOrBytesPath | None = None,
1797 env: _ENV | None = None,
1798 universal_newlines: Literal[False] | None = None,
1799 startupinfo: Any | None = None,
1800 creationflags: int = 0,
1801 restore_signals: bool = True,
1802 start_new_session: bool = False,
1803 pass_fds: Collection[int] = (),
1804 *,
1805 text: Literal[False] | None = None,
1806 encoding: None = None,
1807 errors: None = None,
1808 user: str | int | None = None,
1809 group: str | int | None = None,
1810 extra_groups: Iterable[str | int] | None = None,
1811 umask: int = -1,
1812 pipesize: int = -1,
1813 ) -> None: ...
1814 @overload
1815 def __init__(
1816 self: Popen[Any],
1817 args: _CMD,
1818 bufsize: int = -1,
1819 executable: StrOrBytesPath | None = None,
1820 stdin: _FILE | None = None,
1821 stdout: _FILE | None = None,
1822 stderr: _FILE | None = None,
1823 preexec_fn: Callable[[], object] | None = None,
1824 close_fds: bool = True,
1825 shell: bool = False,
1826 cwd: StrOrBytesPath | None = None,
1827 env: _ENV | None = None,
1828 universal_newlines: bool | None = None,
1829 startupinfo: Any | None = None,
1830 creationflags: int = 0,
1831 restore_signals: bool = True,
1832 start_new_session: bool = False,
1833 pass_fds: Collection[int] = (),
1834 *,
1835 text: bool | None = None,
1836 encoding: str | None = None,
1837 errors: str | None = None,
1838 user: str | int | None = None,
1839 group: str | int | None = None,
1840 extra_groups: Iterable[str | int] | None = None,
1841 umask: int = -1,
1842 pipesize: int = -1,
1843 ) -> None: ...
1844 else:
1845 @overload
1846 def __init__(
1847 self: Popen[str],
1848 args: _CMD,
1849 bufsize: int = -1,
1850 executable: StrOrBytesPath | None = None,
1851 stdin: _FILE | None = None,
1852 stdout: _FILE | None = None,
1853 stderr: _FILE | None = None,
1854 preexec_fn: Callable[[], object] | None = None,
1855 close_fds: bool = True,
1856 shell: bool = False,
1857 cwd: StrOrBytesPath | None = None,
1858 env: _ENV | None = None,
1859 universal_newlines: bool | None = None,
1860 startupinfo: Any | None = None,
1861 creationflags: int = 0,
1862 restore_signals: bool = True,
1863 start_new_session: bool = False,
1864 pass_fds: Collection[int] = (),
1865 *,
1866 text: bool | None = None,
1867 encoding: str,
1868 errors: str | None = None,
1869 user: str | int | None = None,
1870 group: str | int | None = None,
1871 extra_groups: Iterable[str | int] | None = None,
1872 umask: int = -1,
1873 ) -> None: ...
1874 @overload
1875 def __init__(
1876 self: Popen[str],
1877 args: _CMD,
1878 bufsize: int = -1,
1879 executable: StrOrBytesPath | None = None,
1880 stdin: _FILE | None = None,
1881 stdout: _FILE | None = None,
1882 stderr: _FILE | None = None,
1883 preexec_fn: Callable[[], object] | None = None,
1884 close_fds: bool = True,
1885 shell: bool = False,
1886 cwd: StrOrBytesPath | None = None,
1887 env: _ENV | None = None,
1888 universal_newlines: bool | None = None,
1889 startupinfo: Any | None = None,
1890 creationflags: int = 0,
1891 restore_signals: bool = True,
1892 start_new_session: bool = False,
1893 pass_fds: Collection[int] = (),
1894 *,
1895 text: bool | None = None,
1896 encoding: str | None = None,
1897 errors: str,
1898 user: str | int | None = None,
1899 group: str | int | None = None,
1900 extra_groups: Iterable[str | int] | None = None,
1901 umask: int = -1,
1902 ) -> None: ...
1903 @overload
1904 def __init__(
1905 self: Popen[str],
1906 args: _CMD,
1907 bufsize: int = -1,
1908 executable: StrOrBytesPath | None = None,
1909 stdin: _FILE | None = None,
1910 stdout: _FILE | None = None,
1911 stderr: _FILE | None = None,
1912 preexec_fn: Callable[[], object] | None = None,
1913 close_fds: bool = True,
1914 shell: bool = False,
1915 cwd: StrOrBytesPath | None = None,
1916 env: _ENV | None = None,
1917 *,
1918 universal_newlines: Literal[True],
1919 startupinfo: Any | None = None,
1920 creationflags: int = 0,
1921 restore_signals: bool = True,
1922 start_new_session: bool = False,
1923 pass_fds: Collection[int] = (),
1924 # where the *real* keyword only args start
1925 text: bool | None = None,
1926 encoding: str | None = None,
1927 errors: str | None = None,
1928 user: str | int | None = None,
1929 group: str | int | None = None,
1930 extra_groups: Iterable[str | int] | None = None,
1931 umask: int = -1,
1932 ) -> None: ...
1933 @overload
1934 def __init__(
1935 self: Popen[str],
1936 args: _CMD,
1937 bufsize: int = -1,
1938 executable: StrOrBytesPath | None = None,
1939 stdin: _FILE | None = None,
1940 stdout: _FILE | None = None,
1941 stderr: _FILE | None = None,
1942 preexec_fn: Callable[[], object] | None = None,
1943 close_fds: bool = True,
1944 shell: bool = False,
1945 cwd: StrOrBytesPath | None = None,
1946 env: _ENV | None = None,
1947 universal_newlines: bool | None = None,
1948 startupinfo: Any | None = None,
1949 creationflags: int = 0,
1950 restore_signals: bool = True,
1951 start_new_session: bool = False,
1952 pass_fds: Collection[int] = (),
1953 *,
1954 text: Literal[True],
1955 encoding: str | None = None,
1956 errors: str | None = None,
1957 user: str | int | None = None,
1958 group: str | int | None = None,
1959 extra_groups: Iterable[str | int] | None = None,
1960 umask: int = -1,
1961 ) -> None: ...
1962 @overload
1963 def __init__(
1964 self: Popen[bytes],
1965 args: _CMD,
1966 bufsize: int = -1,
1967 executable: StrOrBytesPath | None = None,
1968 stdin: _FILE | None = None,
1969 stdout: _FILE | None = None,
1970 stderr: _FILE | None = None,
1971 preexec_fn: Callable[[], object] | None = None,
1972 close_fds: bool = True,
1973 shell: bool = False,
1974 cwd: StrOrBytesPath | None = None,
1975 env: _ENV | None = None,
1976 universal_newlines: Literal[False] | None = None,
1977 startupinfo: Any | None = None,
1978 creationflags: int = 0,
1979 restore_signals: bool = True,
1980 start_new_session: bool = False,
1981 pass_fds: Collection[int] = (),
1982 *,
1983 text: Literal[False] | None = None,
1984 encoding: None = None,
1985 errors: None = None,
1986 user: str | int | None = None,
1987 group: str | int | None = None,
1988 extra_groups: Iterable[str | int] | None = None,
1989 umask: int = -1,
1990 ) -> None: ...
1991 @overload
1992 def __init__(
1993 self: Popen[Any],
1994 args: _CMD,
1995 bufsize: int = -1,
1996 executable: StrOrBytesPath | None = None,
1997 stdin: _FILE | None = None,
1998 stdout: _FILE | None = None,
1999 stderr: _FILE | None = None,
2000 preexec_fn: Callable[[], object] | None = None,
2001 close_fds: bool = True,
2002 shell: bool = False,
2003 cwd: StrOrBytesPath | None = None,
2004 env: _ENV | None = None,
2005 universal_newlines: bool | None = None,
2006 startupinfo: Any | None = None,
2007 creationflags: int = 0,
2008 restore_signals: bool = True,
2009 start_new_session: bool = False,
2010 pass_fds: Collection[int] = (),
2011 *,
2012 text: bool | None = None,
2013 encoding: str | None = None,
2014 errors: str | None = None,
2015 user: str | int | None = None,
2016 group: str | int | None = None,
2017 extra_groups: Iterable[str | int] | None = None,
2018 umask: int = -1,
2019 ) -> None: ...
2020
2021 def poll(self) -> int | None: ...
2022 def wait(self, timeout: float | None = None) -> int: ...
2023 # morally the members of the returned tuple should be optional
2024 # TODO: this should allow ReadableBuffer for Popen[bytes], but adding
2025 # overloads for that runs into a mypy bug (python/mypy#14070).
2026 def communicate(self, input: AnyStr | None = None, timeout: float | None = None) -> tuple[AnyStr, AnyStr]: ...
2027 def send_signal(self, sig: int) -> None: ...
2028 def terminate(self) -> None: ...
2029 def kill(self) -> None: ...
2030 def __enter__(self) -> Self: ...
2031 def __exit__(
2032 self, exc_type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
2033 ) -> None: ...
2034 def __del__(self) -> None: ...
2035 def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
2036
2037 # The result really is always a str.
2038 if sys.version_info >= (3, 11):
2039 def getstatusoutput(cmd: _CMD, *, encoding: str | None = None, errors: str | None = None) -> tuple[int, str]: ...
2040 def getoutput(cmd: _CMD, *, encoding: str | None = None, errors: str | None = None) -> str: ...
2041
2042 else:
2043 def getstatusoutput(cmd: _CMD) -> tuple[int, str]: ...
2044 def getoutput(cmd: _CMD) -> str: ...
2045
2046 def list2cmdline(seq: Iterable[StrOrBytesPath]) -> str: ... # undocumented
2047
2048 if sys.platform == "win32":
2049 if sys.version_info >= (3, 13):
2050 from _winapi import STARTF_FORCEOFFFEEDBACK, STARTF_FORCEONFEEDBACK
2051
2052 __all__ += ["STARTF_FORCEOFFFEEDBACK", "STARTF_FORCEONFEEDBACK"]
2053
2054 class STARTUPINFO:
2055 def __init__(
2056 self,
2057 *,
2058 dwFlags: int = 0,
2059 hStdInput: Any | None = None,
2060 hStdOutput: Any | None = None,
2061 hStdError: Any | None = None,
2062 wShowWindow: int = 0,
2063 lpAttributeList: Mapping[str, Any] | None = None,
2064 ) -> None: ...
2065 dwFlags: int
2066 hStdInput: Any | None
2067 hStdOutput: Any | None
2068 hStdError: Any | None
2069 wShowWindow: int
2070 lpAttributeList: Mapping[str, Any]
2071 def copy(self) -> STARTUPINFO: ...
2072
2073 from _winapi import (
2074 ABOVE_NORMAL_PRIORITY_CLASS as ABOVE_NORMAL_PRIORITY_CLASS,
2075 BELOW_NORMAL_PRIORITY_CLASS as BELOW_NORMAL_PRIORITY_CLASS,
2076 CREATE_BREAKAWAY_FROM_JOB as CREATE_BREAKAWAY_FROM_JOB,
2077 CREATE_DEFAULT_ERROR_MODE as CREATE_DEFAULT_ERROR_MODE,
2078 CREATE_NEW_CONSOLE as CREATE_NEW_CONSOLE,
2079 CREATE_NEW_PROCESS_GROUP as CREATE_NEW_PROCESS_GROUP,
2080 CREATE_NO_WINDOW as CREATE_NO_WINDOW,
2081 DETACHED_PROCESS as DETACHED_PROCESS,
2082 HIGH_PRIORITY_CLASS as HIGH_PRIORITY_CLASS,
2083 IDLE_PRIORITY_CLASS as IDLE_PRIORITY_CLASS,
2084 NORMAL_PRIORITY_CLASS as NORMAL_PRIORITY_CLASS,
2085 REALTIME_PRIORITY_CLASS as REALTIME_PRIORITY_CLASS,
2086 STARTF_USESHOWWINDOW as STARTF_USESHOWWINDOW,
2087 STARTF_USESTDHANDLES as STARTF_USESTDHANDLES,
2088 STD_ERROR_HANDLE as STD_ERROR_HANDLE,
2089 STD_INPUT_HANDLE as STD_INPUT_HANDLE,
2090 STD_OUTPUT_HANDLE as STD_OUTPUT_HANDLE,
2091 SW_HIDE as SW_HIDE,
2092 )