massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / subprocess.pyi
1 import sys
2 from _typeshed import Self, StrOrBytesPath
3 from types import TracebackType
4 from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Mapping, Sequence, Type, TypeVar, Union, overload
5 from typing_extensions import Literal
6
7 if sys.version_info >= (3, 9):
8     from types import GenericAlias
9
10 # We prefer to annotate inputs to methods (eg subprocess.check_call) with these
11 # union types.
12 # For outputs we use laborious literal based overloads to try to determine
13 # which specific return types to use, and prefer to fall back to Any when
14 # this does not work, so the caller does not have to use an assertion to confirm
15 # which type.
16 #
17 # For example:
18 #
19 # try:
20 #    x = subprocess.check_output(["ls", "-l"])
21 #    reveal_type(x)  # bytes, based on the overloads
22 # except TimeoutError as e:
23 #    reveal_type(e.cmd)  # Any, but morally is _CMD
24 _FILE = Union[None, int, IO[Any]]
25 _TXT = Union[bytes, str]
26 if sys.version_info >= (3, 8):
27     _CMD = Union[StrOrBytesPath, Sequence[StrOrBytesPath]]
28 else:
29     # Python 3.6 doesn't support _CMD being a single PathLike.
30     # See: https://bugs.python.org/issue31961
31     _CMD = Union[_TXT, Sequence[StrOrBytesPath]]
32 if sys.platform == "win32":
33     _ENV = Mapping[str, str]
34 else:
35     _ENV = Union[Mapping[bytes, StrOrBytesPath], Mapping[str, StrOrBytesPath]]
36
37 _T = TypeVar("_T")
38
39 class CompletedProcess(Generic[_T]):
40     # morally: _CMD
41     args: Any
42     returncode: int
43     # These can both be None, but requiring checks for None would be tedious
44     # and writing all the overloads would be horrific.
45     stdout: _T
46     stderr: _T
47     def __init__(self, args: _CMD, returncode: int, stdout: _T | None = ..., stderr: _T | None = ...) -> None: ...
48     def check_returncode(self) -> None: ...
49     if sys.version_info >= (3, 9):
50         def __class_getitem__(cls, item: Any) -> GenericAlias: ...
51
52 if sys.version_info >= (3, 7):
53     # Nearly the same args as for 3.6, except for capture_output and text
54     @overload
55     def run(
56         args: _CMD,
57         bufsize: int = ...,
58         executable: StrOrBytesPath | None = ...,
59         stdin: _FILE = ...,
60         stdout: _FILE = ...,
61         stderr: _FILE = ...,
62         preexec_fn: Callable[[], Any] | None = ...,
63         close_fds: bool = ...,
64         shell: bool = ...,
65         cwd: StrOrBytesPath | None = ...,
66         env: _ENV | None = ...,
67         universal_newlines: bool = ...,
68         startupinfo: Any = ...,
69         creationflags: int = ...,
70         restore_signals: bool = ...,
71         start_new_session: bool = ...,
72         pass_fds: Any = ...,
73         *,
74         capture_output: bool = ...,
75         check: bool = ...,
76         encoding: str | None = ...,
77         errors: str | None = ...,
78         input: str | None = ...,
79         text: Literal[True],
80         timeout: float | None = ...,
81     ) -> CompletedProcess[str]: ...
82     @overload
83     def run(
84         args: _CMD,
85         bufsize: int = ...,
86         executable: StrOrBytesPath | None = ...,
87         stdin: _FILE = ...,
88         stdout: _FILE = ...,
89         stderr: _FILE = ...,
90         preexec_fn: Callable[[], Any] | None = ...,
91         close_fds: bool = ...,
92         shell: bool = ...,
93         cwd: StrOrBytesPath | None = ...,
94         env: _ENV | None = ...,
95         universal_newlines: bool = ...,
96         startupinfo: Any = ...,
97         creationflags: int = ...,
98         restore_signals: bool = ...,
99         start_new_session: bool = ...,
100         pass_fds: Any = ...,
101         *,
102         capture_output: bool = ...,
103         check: bool = ...,
104         encoding: str,
105         errors: str | None = ...,
106         input: str | None = ...,
107         text: bool | None = ...,
108         timeout: float | None = ...,
109     ) -> CompletedProcess[str]: ...
110     @overload
111     def run(
112         args: _CMD,
113         bufsize: int = ...,
114         executable: StrOrBytesPath | None = ...,
115         stdin: _FILE = ...,
116         stdout: _FILE = ...,
117         stderr: _FILE = ...,
118         preexec_fn: Callable[[], Any] | None = ...,
119         close_fds: bool = ...,
120         shell: bool = ...,
121         cwd: StrOrBytesPath | None = ...,
122         env: _ENV | None = ...,
123         universal_newlines: bool = ...,
124         startupinfo: Any = ...,
125         creationflags: int = ...,
126         restore_signals: bool = ...,
127         start_new_session: bool = ...,
128         pass_fds: Any = ...,
129         *,
130         capture_output: bool = ...,
131         check: bool = ...,
132         encoding: str | None = ...,
133         errors: str,
134         input: str | None = ...,
135         text: bool | None = ...,
136         timeout: float | None = ...,
137     ) -> CompletedProcess[str]: ...
138     @overload
139     def run(
140         args: _CMD,
141         bufsize: int = ...,
142         executable: StrOrBytesPath | None = ...,
143         stdin: _FILE = ...,
144         stdout: _FILE = ...,
145         stderr: _FILE = ...,
146         preexec_fn: Callable[[], Any] | None = ...,
147         close_fds: bool = ...,
148         shell: bool = ...,
149         cwd: StrOrBytesPath | None = ...,
150         env: _ENV | None = ...,
151         *,
152         universal_newlines: Literal[True],
153         startupinfo: Any = ...,
154         creationflags: int = ...,
155         restore_signals: bool = ...,
156         start_new_session: bool = ...,
157         pass_fds: Any = ...,
158         # where the *real* keyword only args start
159         capture_output: bool = ...,
160         check: bool = ...,
161         encoding: str | None = ...,
162         errors: str | None = ...,
163         input: str | None = ...,
164         text: bool | None = ...,
165         timeout: float | None = ...,
166     ) -> CompletedProcess[str]: ...
167     @overload
168     def run(
169         args: _CMD,
170         bufsize: int = ...,
171         executable: StrOrBytesPath | None = ...,
172         stdin: _FILE = ...,
173         stdout: _FILE = ...,
174         stderr: _FILE = ...,
175         preexec_fn: Callable[[], Any] | None = ...,
176         close_fds: bool = ...,
177         shell: bool = ...,
178         cwd: StrOrBytesPath | None = ...,
179         env: _ENV | None = ...,
180         universal_newlines: Literal[False] = ...,
181         startupinfo: Any = ...,
182         creationflags: int = ...,
183         restore_signals: bool = ...,
184         start_new_session: bool = ...,
185         pass_fds: Any = ...,
186         *,
187         capture_output: bool = ...,
188         check: bool = ...,
189         encoding: None = ...,
190         errors: None = ...,
191         input: bytes | None = ...,
192         text: Literal[None, False] = ...,
193         timeout: float | None = ...,
194     ) -> CompletedProcess[bytes]: ...
195     @overload
196     def run(
197         args: _CMD,
198         bufsize: int = ...,
199         executable: StrOrBytesPath | None = ...,
200         stdin: _FILE = ...,
201         stdout: _FILE = ...,
202         stderr: _FILE = ...,
203         preexec_fn: Callable[[], Any] | None = ...,
204         close_fds: bool = ...,
205         shell: bool = ...,
206         cwd: StrOrBytesPath | None = ...,
207         env: _ENV | None = ...,
208         universal_newlines: bool = ...,
209         startupinfo: Any = ...,
210         creationflags: int = ...,
211         restore_signals: bool = ...,
212         start_new_session: bool = ...,
213         pass_fds: Any = ...,
214         *,
215         capture_output: bool = ...,
216         check: bool = ...,
217         encoding: str | None = ...,
218         errors: str | None = ...,
219         input: _TXT | None = ...,
220         text: bool | None = ...,
221         timeout: float | None = ...,
222     ) -> CompletedProcess[Any]: ...
223
224 else:
225     # Nearly same args as Popen.__init__ except for timeout, input, and check
226     @overload
227     def run(
228         args: _CMD,
229         bufsize: int = ...,
230         executable: StrOrBytesPath | None = ...,
231         stdin: _FILE = ...,
232         stdout: _FILE = ...,
233         stderr: _FILE = ...,
234         preexec_fn: Callable[[], Any] | None = ...,
235         close_fds: bool = ...,
236         shell: bool = ...,
237         cwd: StrOrBytesPath | None = ...,
238         env: _ENV | None = ...,
239         universal_newlines: bool = ...,
240         startupinfo: Any = ...,
241         creationflags: int = ...,
242         restore_signals: bool = ...,
243         start_new_session: bool = ...,
244         pass_fds: Any = ...,
245         *,
246         check: bool = ...,
247         encoding: str,
248         errors: str | None = ...,
249         input: str | None = ...,
250         timeout: float | None = ...,
251     ) -> CompletedProcess[str]: ...
252     @overload
253     def run(
254         args: _CMD,
255         bufsize: int = ...,
256         executable: StrOrBytesPath | None = ...,
257         stdin: _FILE = ...,
258         stdout: _FILE = ...,
259         stderr: _FILE = ...,
260         preexec_fn: Callable[[], Any] | None = ...,
261         close_fds: bool = ...,
262         shell: bool = ...,
263         cwd: StrOrBytesPath | None = ...,
264         env: _ENV | None = ...,
265         universal_newlines: bool = ...,
266         startupinfo: Any = ...,
267         creationflags: int = ...,
268         restore_signals: bool = ...,
269         start_new_session: bool = ...,
270         pass_fds: Any = ...,
271         *,
272         check: bool = ...,
273         encoding: str | None = ...,
274         errors: str,
275         input: str | None = ...,
276         timeout: float | None = ...,
277     ) -> CompletedProcess[str]: ...
278     @overload
279     def run(
280         args: _CMD,
281         bufsize: int = ...,
282         executable: StrOrBytesPath | None = ...,
283         stdin: _FILE = ...,
284         stdout: _FILE = ...,
285         stderr: _FILE = ...,
286         preexec_fn: Callable[[], Any] | None = ...,
287         close_fds: bool = ...,
288         shell: bool = ...,
289         cwd: StrOrBytesPath | None = ...,
290         env: _ENV | None = ...,
291         *,
292         universal_newlines: Literal[True],
293         startupinfo: Any = ...,
294         creationflags: int = ...,
295         restore_signals: bool = ...,
296         start_new_session: bool = ...,
297         pass_fds: Any = ...,
298         # where the *real* keyword only args start
299         check: bool = ...,
300         encoding: str | None = ...,
301         errors: str | None = ...,
302         input: str | None = ...,
303         timeout: float | None = ...,
304     ) -> CompletedProcess[str]: ...
305     @overload
306     def run(
307         args: _CMD,
308         bufsize: int = ...,
309         executable: StrOrBytesPath | None = ...,
310         stdin: _FILE = ...,
311         stdout: _FILE = ...,
312         stderr: _FILE = ...,
313         preexec_fn: Callable[[], Any] | None = ...,
314         close_fds: bool = ...,
315         shell: bool = ...,
316         cwd: StrOrBytesPath | None = ...,
317         env: _ENV | None = ...,
318         universal_newlines: Literal[False] = ...,
319         startupinfo: Any = ...,
320         creationflags: int = ...,
321         restore_signals: bool = ...,
322         start_new_session: bool = ...,
323         pass_fds: Any = ...,
324         *,
325         check: bool = ...,
326         encoding: None = ...,
327         errors: None = ...,
328         input: bytes | None = ...,
329         timeout: float | None = ...,
330     ) -> CompletedProcess[bytes]: ...
331     @overload
332     def run(
333         args: _CMD,
334         bufsize: int = ...,
335         executable: StrOrBytesPath | None = ...,
336         stdin: _FILE = ...,
337         stdout: _FILE = ...,
338         stderr: _FILE = ...,
339         preexec_fn: Callable[[], Any] | None = ...,
340         close_fds: bool = ...,
341         shell: bool = ...,
342         cwd: StrOrBytesPath | None = ...,
343         env: _ENV | None = ...,
344         universal_newlines: bool = ...,
345         startupinfo: Any = ...,
346         creationflags: int = ...,
347         restore_signals: bool = ...,
348         start_new_session: bool = ...,
349         pass_fds: Any = ...,
350         *,
351         check: bool = ...,
352         encoding: str | None = ...,
353         errors: str | None = ...,
354         input: _TXT | None = ...,
355         timeout: float | None = ...,
356     ) -> CompletedProcess[Any]: ...
357
358 # Same args as Popen.__init__
359 def call(
360     args: _CMD,
361     bufsize: int = ...,
362     executable: StrOrBytesPath | None = ...,
363     stdin: _FILE = ...,
364     stdout: _FILE = ...,
365     stderr: _FILE = ...,
366     preexec_fn: Callable[[], Any] | None = ...,
367     close_fds: bool = ...,
368     shell: bool = ...,
369     cwd: StrOrBytesPath | None = ...,
370     env: _ENV | None = ...,
371     universal_newlines: bool = ...,
372     startupinfo: Any = ...,
373     creationflags: int = ...,
374     restore_signals: bool = ...,
375     start_new_session: bool = ...,
376     pass_fds: Any = ...,
377     *,
378     timeout: float | None = ...,
379 ) -> int: ...
380
381 # Same args as Popen.__init__
382 def check_call(
383     args: _CMD,
384     bufsize: int = ...,
385     executable: StrOrBytesPath = ...,
386     stdin: _FILE = ...,
387     stdout: _FILE = ...,
388     stderr: _FILE = ...,
389     preexec_fn: Callable[[], Any] | None = ...,
390     close_fds: bool = ...,
391     shell: bool = ...,
392     cwd: StrOrBytesPath | None = ...,
393     env: _ENV | None = ...,
394     universal_newlines: bool = ...,
395     startupinfo: Any = ...,
396     creationflags: int = ...,
397     restore_signals: bool = ...,
398     start_new_session: bool = ...,
399     pass_fds: Any = ...,
400     timeout: float | None = ...,
401 ) -> int: ...
402
403 if sys.version_info >= (3, 7):
404     # 3.7 added text
405     @overload
406     def check_output(
407         args: _CMD,
408         bufsize: int = ...,
409         executable: StrOrBytesPath | None = ...,
410         stdin: _FILE = ...,
411         stderr: _FILE = ...,
412         preexec_fn: Callable[[], Any] | None = ...,
413         close_fds: bool = ...,
414         shell: bool = ...,
415         cwd: StrOrBytesPath | None = ...,
416         env: _ENV | None = ...,
417         universal_newlines: bool = ...,
418         startupinfo: Any = ...,
419         creationflags: int = ...,
420         restore_signals: bool = ...,
421         start_new_session: bool = ...,
422         pass_fds: Any = ...,
423         *,
424         timeout: float | None = ...,
425         input: _TXT | None = ...,
426         encoding: str | None = ...,
427         errors: str | None = ...,
428         text: Literal[True],
429     ) -> str: ...
430     @overload
431     def check_output(
432         args: _CMD,
433         bufsize: int = ...,
434         executable: StrOrBytesPath | None = ...,
435         stdin: _FILE = ...,
436         stderr: _FILE = ...,
437         preexec_fn: Callable[[], Any] | None = ...,
438         close_fds: bool = ...,
439         shell: bool = ...,
440         cwd: StrOrBytesPath | None = ...,
441         env: _ENV | None = ...,
442         universal_newlines: bool = ...,
443         startupinfo: Any = ...,
444         creationflags: int = ...,
445         restore_signals: bool = ...,
446         start_new_session: bool = ...,
447         pass_fds: Any = ...,
448         *,
449         timeout: float | None = ...,
450         input: _TXT | None = ...,
451         encoding: str,
452         errors: str | None = ...,
453         text: bool | None = ...,
454     ) -> str: ...
455     @overload
456     def check_output(
457         args: _CMD,
458         bufsize: int = ...,
459         executable: StrOrBytesPath | None = ...,
460         stdin: _FILE = ...,
461         stderr: _FILE = ...,
462         preexec_fn: Callable[[], Any] | None = ...,
463         close_fds: bool = ...,
464         shell: bool = ...,
465         cwd: StrOrBytesPath | None = ...,
466         env: _ENV | None = ...,
467         universal_newlines: bool = ...,
468         startupinfo: Any = ...,
469         creationflags: int = ...,
470         restore_signals: bool = ...,
471         start_new_session: bool = ...,
472         pass_fds: Any = ...,
473         *,
474         timeout: float | None = ...,
475         input: _TXT | None = ...,
476         encoding: str | None = ...,
477         errors: str,
478         text: bool | None = ...,
479     ) -> str: ...
480     @overload
481     def check_output(
482         args: _CMD,
483         bufsize: int = ...,
484         executable: StrOrBytesPath | None = ...,
485         stdin: _FILE = ...,
486         stderr: _FILE = ...,
487         preexec_fn: Callable[[], Any] | None = ...,
488         close_fds: bool = ...,
489         shell: bool = ...,
490         cwd: StrOrBytesPath | None = ...,
491         env: _ENV | None = ...,
492         *,
493         universal_newlines: Literal[True],
494         startupinfo: Any = ...,
495         creationflags: int = ...,
496         restore_signals: bool = ...,
497         start_new_session: bool = ...,
498         pass_fds: Any = ...,
499         # where the real keyword only ones start
500         timeout: float | None = ...,
501         input: _TXT | None = ...,
502         encoding: str | None = ...,
503         errors: str | None = ...,
504         text: bool | None = ...,
505     ) -> str: ...
506     @overload
507     def check_output(
508         args: _CMD,
509         bufsize: int = ...,
510         executable: StrOrBytesPath | None = ...,
511         stdin: _FILE = ...,
512         stderr: _FILE = ...,
513         preexec_fn: Callable[[], Any] | None = ...,
514         close_fds: bool = ...,
515         shell: bool = ...,
516         cwd: StrOrBytesPath | None = ...,
517         env: _ENV | None = ...,
518         universal_newlines: Literal[False] = ...,
519         startupinfo: Any = ...,
520         creationflags: int = ...,
521         restore_signals: bool = ...,
522         start_new_session: bool = ...,
523         pass_fds: Any = ...,
524         *,
525         timeout: float | None = ...,
526         input: _TXT | None = ...,
527         encoding: None = ...,
528         errors: None = ...,
529         text: Literal[None, False] = ...,
530     ) -> bytes: ...
531     @overload
532     def check_output(
533         args: _CMD,
534         bufsize: int = ...,
535         executable: StrOrBytesPath | None = ...,
536         stdin: _FILE = ...,
537         stderr: _FILE = ...,
538         preexec_fn: Callable[[], Any] | None = ...,
539         close_fds: bool = ...,
540         shell: bool = ...,
541         cwd: StrOrBytesPath | None = ...,
542         env: _ENV | None = ...,
543         universal_newlines: bool = ...,
544         startupinfo: Any = ...,
545         creationflags: int = ...,
546         restore_signals: bool = ...,
547         start_new_session: bool = ...,
548         pass_fds: Any = ...,
549         *,
550         timeout: float | None = ...,
551         input: _TXT | None = ...,
552         encoding: str | None = ...,
553         errors: str | None = ...,
554         text: bool | None = ...,
555     ) -> Any: ...  # morally: -> _TXT
556
557 else:
558     @overload
559     def check_output(
560         args: _CMD,
561         bufsize: int = ...,
562         executable: StrOrBytesPath | None = ...,
563         stdin: _FILE = ...,
564         stderr: _FILE = ...,
565         preexec_fn: Callable[[], Any] | None = ...,
566         close_fds: bool = ...,
567         shell: bool = ...,
568         cwd: StrOrBytesPath | None = ...,
569         env: _ENV | None = ...,
570         universal_newlines: bool = ...,
571         startupinfo: Any = ...,
572         creationflags: int = ...,
573         restore_signals: bool = ...,
574         start_new_session: bool = ...,
575         pass_fds: Any = ...,
576         *,
577         timeout: float | None = ...,
578         input: _TXT | None = ...,
579         encoding: str,
580         errors: str | None = ...,
581     ) -> str: ...
582     @overload
583     def check_output(
584         args: _CMD,
585         bufsize: int = ...,
586         executable: StrOrBytesPath | None = ...,
587         stdin: _FILE = ...,
588         stderr: _FILE = ...,
589         preexec_fn: Callable[[], Any] | None = ...,
590         close_fds: bool = ...,
591         shell: bool = ...,
592         cwd: StrOrBytesPath | None = ...,
593         env: _ENV | None = ...,
594         universal_newlines: bool = ...,
595         startupinfo: Any = ...,
596         creationflags: int = ...,
597         restore_signals: bool = ...,
598         start_new_session: bool = ...,
599         pass_fds: Any = ...,
600         *,
601         timeout: float | None = ...,
602         input: _TXT | None = ...,
603         encoding: str | None = ...,
604         errors: str,
605     ) -> str: ...
606     @overload
607     def check_output(
608         args: _CMD,
609         bufsize: int = ...,
610         executable: StrOrBytesPath | None = ...,
611         stdin: _FILE = ...,
612         stderr: _FILE = ...,
613         preexec_fn: Callable[[], Any] | None = ...,
614         close_fds: bool = ...,
615         shell: bool = ...,
616         cwd: StrOrBytesPath | None = ...,
617         env: _ENV | None = ...,
618         startupinfo: Any = ...,
619         creationflags: int = ...,
620         restore_signals: bool = ...,
621         start_new_session: bool = ...,
622         pass_fds: Any = ...,
623         *,
624         universal_newlines: Literal[True],
625         timeout: float | None = ...,
626         input: _TXT | None = ...,
627         encoding: str | None = ...,
628         errors: str | None = ...,
629     ) -> str: ...
630     @overload
631     def check_output(
632         args: _CMD,
633         bufsize: int = ...,
634         executable: StrOrBytesPath | None = ...,
635         stdin: _FILE = ...,
636         stderr: _FILE = ...,
637         preexec_fn: Callable[[], Any] | None = ...,
638         close_fds: bool = ...,
639         shell: bool = ...,
640         cwd: StrOrBytesPath | None = ...,
641         env: _ENV | None = ...,
642         universal_newlines: Literal[False] = ...,
643         startupinfo: Any = ...,
644         creationflags: int = ...,
645         restore_signals: bool = ...,
646         start_new_session: bool = ...,
647         pass_fds: Any = ...,
648         *,
649         timeout: float | None = ...,
650         input: _TXT | None = ...,
651         encoding: None = ...,
652         errors: None = ...,
653     ) -> bytes: ...
654     @overload
655     def check_output(
656         args: _CMD,
657         bufsize: int = ...,
658         executable: StrOrBytesPath | None = ...,
659         stdin: _FILE = ...,
660         stderr: _FILE = ...,
661         preexec_fn: Callable[[], Any] | None = ...,
662         close_fds: bool = ...,
663         shell: bool = ...,
664         cwd: StrOrBytesPath | None = ...,
665         env: _ENV | None = ...,
666         universal_newlines: bool = ...,
667         startupinfo: Any = ...,
668         creationflags: int = ...,
669         restore_signals: bool = ...,
670         start_new_session: bool = ...,
671         pass_fds: Any = ...,
672         *,
673         timeout: float | None = ...,
674         input: _TXT | None = ...,
675         encoding: str | None = ...,
676         errors: str | None = ...,
677     ) -> Any: ...  # morally: -> _TXT
678
679 PIPE: int
680 STDOUT: int
681 DEVNULL: int
682
683 class SubprocessError(Exception): ...
684
685 class TimeoutExpired(SubprocessError):
686     def __init__(self, cmd: _CMD, timeout: float, output: _TXT | None = ..., stderr: _TXT | None = ...) -> None: ...
687     # morally: _CMD
688     cmd: Any
689     timeout: float
690     # morally: _TXT | None
691     output: Any
692     stdout: Any
693     stderr: Any
694
695 class CalledProcessError(SubprocessError):
696     returncode: int
697     # morally: _CMD
698     cmd: Any
699     # morally: _TXT | None
700     output: Any
701
702     # morally: _TXT | None
703     stdout: Any
704     stderr: Any
705     def __init__(self, returncode: int, cmd: _CMD, output: _TXT | None = ..., stderr: _TXT | None = ...) -> None: ...
706
707 class Popen(Generic[AnyStr]):
708     args: _CMD
709     stdin: IO[AnyStr] | None
710     stdout: IO[AnyStr] | None
711     stderr: IO[AnyStr] | None
712     pid: int
713     returncode: int
714     universal_newlines: bool
715
716     # Technically it is wrong that Popen provides __new__ instead of __init__
717     # but this shouldn't come up hopefully?
718
719     if sys.version_info >= (3, 7):
720         # text is added in 3.7
721         @overload
722         def __new__(
723             cls,
724             args: _CMD,
725             bufsize: int = ...,
726             executable: StrOrBytesPath | None = ...,
727             stdin: _FILE | None = ...,
728             stdout: _FILE | None = ...,
729             stderr: _FILE | None = ...,
730             preexec_fn: Callable[[], Any] | None = ...,
731             close_fds: bool = ...,
732             shell: bool = ...,
733             cwd: StrOrBytesPath | None = ...,
734             env: _ENV | None = ...,
735             universal_newlines: bool = ...,
736             startupinfo: Any | None = ...,
737             creationflags: int = ...,
738             restore_signals: bool = ...,
739             start_new_session: bool = ...,
740             pass_fds: Any = ...,
741             *,
742             text: bool | None = ...,
743             encoding: str,
744             errors: str | None = ...,
745         ) -> Popen[str]: ...
746         @overload
747         def __new__(
748             cls,
749             args: _CMD,
750             bufsize: int = ...,
751             executable: StrOrBytesPath | None = ...,
752             stdin: _FILE | None = ...,
753             stdout: _FILE | None = ...,
754             stderr: _FILE | None = ...,
755             preexec_fn: Callable[[], Any] | None = ...,
756             close_fds: bool = ...,
757             shell: bool = ...,
758             cwd: StrOrBytesPath | None = ...,
759             env: _ENV | None = ...,
760             universal_newlines: bool = ...,
761             startupinfo: Any | None = ...,
762             creationflags: int = ...,
763             restore_signals: bool = ...,
764             start_new_session: bool = ...,
765             pass_fds: Any = ...,
766             *,
767             text: bool | None = ...,
768             encoding: str | None = ...,
769             errors: str,
770         ) -> Popen[str]: ...
771         @overload
772         def __new__(
773             cls,
774             args: _CMD,
775             bufsize: int = ...,
776             executable: StrOrBytesPath | None = ...,
777             stdin: _FILE | None = ...,
778             stdout: _FILE | None = ...,
779             stderr: _FILE | None = ...,
780             preexec_fn: Callable[[], Any] | None = ...,
781             close_fds: bool = ...,
782             shell: bool = ...,
783             cwd: StrOrBytesPath | None = ...,
784             env: _ENV | None = ...,
785             *,
786             universal_newlines: Literal[True],
787             startupinfo: Any | None = ...,
788             creationflags: int = ...,
789             restore_signals: bool = ...,
790             start_new_session: bool = ...,
791             pass_fds: Any = ...,
792             # where the *real* keyword only args start
793             text: bool | None = ...,
794             encoding: str | None = ...,
795             errors: str | None = ...,
796         ) -> Popen[str]: ...
797         @overload
798         def __new__(
799             cls,
800             args: _CMD,
801             bufsize: int = ...,
802             executable: StrOrBytesPath | None = ...,
803             stdin: _FILE | None = ...,
804             stdout: _FILE | None = ...,
805             stderr: _FILE | None = ...,
806             preexec_fn: Callable[[], Any] | None = ...,
807             close_fds: bool = ...,
808             shell: bool = ...,
809             cwd: StrOrBytesPath | None = ...,
810             env: _ENV | None = ...,
811             universal_newlines: bool = ...,
812             startupinfo: Any | None = ...,
813             creationflags: int = ...,
814             restore_signals: bool = ...,
815             start_new_session: bool = ...,
816             pass_fds: Any = ...,
817             *,
818             text: Literal[True],
819             encoding: str | None = ...,
820             errors: str | None = ...,
821         ) -> Popen[str]: ...
822         @overload
823         def __new__(
824             cls,
825             args: _CMD,
826             bufsize: int = ...,
827             executable: StrOrBytesPath | None = ...,
828             stdin: _FILE | None = ...,
829             stdout: _FILE | None = ...,
830             stderr: _FILE | None = ...,
831             preexec_fn: Callable[[], Any] | None = ...,
832             close_fds: bool = ...,
833             shell: bool = ...,
834             cwd: StrOrBytesPath | None = ...,
835             env: _ENV | None = ...,
836             universal_newlines: Literal[False] = ...,
837             startupinfo: Any | None = ...,
838             creationflags: int = ...,
839             restore_signals: bool = ...,
840             start_new_session: bool = ...,
841             pass_fds: Any = ...,
842             *,
843             text: Literal[None, False] = ...,
844             encoding: None = ...,
845             errors: None = ...,
846         ) -> Popen[bytes]: ...
847         @overload
848         def __new__(
849             cls,
850             args: _CMD,
851             bufsize: int = ...,
852             executable: StrOrBytesPath | None = ...,
853             stdin: _FILE | None = ...,
854             stdout: _FILE | None = ...,
855             stderr: _FILE | None = ...,
856             preexec_fn: Callable[[], Any] | None = ...,
857             close_fds: bool = ...,
858             shell: bool = ...,
859             cwd: StrOrBytesPath | None = ...,
860             env: _ENV | None = ...,
861             universal_newlines: bool = ...,
862             startupinfo: Any | None = ...,
863             creationflags: int = ...,
864             restore_signals: bool = ...,
865             start_new_session: bool = ...,
866             pass_fds: Any = ...,
867             *,
868             text: bool | None = ...,
869             encoding: str | None = ...,
870             errors: str | None = ...,
871         ) -> Popen[Any]: ...
872     else:
873         @overload
874         def __new__(
875             cls,
876             args: _CMD,
877             bufsize: int = ...,
878             executable: StrOrBytesPath | None = ...,
879             stdin: _FILE | None = ...,
880             stdout: _FILE | None = ...,
881             stderr: _FILE | None = ...,
882             preexec_fn: Callable[[], Any] | None = ...,
883             close_fds: bool = ...,
884             shell: bool = ...,
885             cwd: StrOrBytesPath | None = ...,
886             env: _ENV | None = ...,
887             universal_newlines: bool = ...,
888             startupinfo: Any | None = ...,
889             creationflags: int = ...,
890             restore_signals: bool = ...,
891             start_new_session: bool = ...,
892             pass_fds: Any = ...,
893             *,
894             encoding: str,
895             errors: str | None = ...,
896         ) -> Popen[str]: ...
897         @overload
898         def __new__(
899             cls,
900             args: _CMD,
901             bufsize: int = ...,
902             executable: StrOrBytesPath | None = ...,
903             stdin: _FILE | None = ...,
904             stdout: _FILE | None = ...,
905             stderr: _FILE | None = ...,
906             preexec_fn: Callable[[], Any] | None = ...,
907             close_fds: bool = ...,
908             shell: bool = ...,
909             cwd: StrOrBytesPath | None = ...,
910             env: _ENV | None = ...,
911             universal_newlines: bool = ...,
912             startupinfo: Any | None = ...,
913             creationflags: int = ...,
914             restore_signals: bool = ...,
915             start_new_session: bool = ...,
916             pass_fds: Any = ...,
917             *,
918             encoding: str | None = ...,
919             errors: str,
920         ) -> Popen[str]: ...
921         @overload
922         def __new__(
923             cls,
924             args: _CMD,
925             bufsize: int = ...,
926             executable: StrOrBytesPath | None = ...,
927             stdin: _FILE | None = ...,
928             stdout: _FILE | None = ...,
929             stderr: _FILE | None = ...,
930             preexec_fn: Callable[[], Any] | None = ...,
931             close_fds: bool = ...,
932             shell: bool = ...,
933             cwd: StrOrBytesPath | None = ...,
934             env: _ENV | None = ...,
935             *,
936             universal_newlines: Literal[True],
937             startupinfo: Any | None = ...,
938             creationflags: int = ...,
939             restore_signals: bool = ...,
940             start_new_session: bool = ...,
941             pass_fds: Any = ...,
942             # where the *real* keyword only args start
943             encoding: str | None = ...,
944             errors: str | None = ...,
945         ) -> Popen[str]: ...
946         @overload
947         def __new__(
948             cls,
949             args: _CMD,
950             bufsize: int = ...,
951             executable: StrOrBytesPath | None = ...,
952             stdin: _FILE | None = ...,
953             stdout: _FILE | None = ...,
954             stderr: _FILE | None = ...,
955             preexec_fn: Callable[[], Any] | None = ...,
956             close_fds: bool = ...,
957             shell: bool = ...,
958             cwd: StrOrBytesPath | None = ...,
959             env: _ENV | None = ...,
960             universal_newlines: Literal[False] = ...,
961             startupinfo: Any | None = ...,
962             creationflags: int = ...,
963             restore_signals: bool = ...,
964             start_new_session: bool = ...,
965             pass_fds: Any = ...,
966             *,
967             encoding: None = ...,
968             errors: None = ...,
969         ) -> Popen[bytes]: ...
970         @overload
971         def __new__(
972             cls,
973             args: _CMD,
974             bufsize: int = ...,
975             executable: StrOrBytesPath | None = ...,
976             stdin: _FILE | None = ...,
977             stdout: _FILE | None = ...,
978             stderr: _FILE | None = ...,
979             preexec_fn: Callable[[], Any] | None = ...,
980             close_fds: bool = ...,
981             shell: bool = ...,
982             cwd: StrOrBytesPath | None = ...,
983             env: _ENV | None = ...,
984             universal_newlines: bool = ...,
985             startupinfo: Any | None = ...,
986             creationflags: int = ...,
987             restore_signals: bool = ...,
988             start_new_session: bool = ...,
989             pass_fds: Any = ...,
990             *,
991             encoding: str | None = ...,
992             errors: str | None = ...,
993         ) -> Popen[Any]: ...
994     def poll(self) -> int | None: ...
995     if sys.version_info >= (3, 7):
996         def wait(self, timeout: float | None = ...) -> int: ...
997     else:
998         def wait(self, timeout: float | None = ..., endtime: float | None = ...) -> int: ...
999     # Return str/bytes
1000     def communicate(
1001         self,
1002         input: AnyStr | None = ...,
1003         timeout: float | None = ...,
1004         # morally this should be optional
1005     ) -> tuple[AnyStr, AnyStr]: ...
1006     def send_signal(self, sig: int) -> None: ...
1007     def terminate(self) -> None: ...
1008     def kill(self) -> None: ...
1009     def __enter__(self: Self) -> Self: ...
1010     def __exit__(
1011         self, type: Type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
1012     ) -> None: ...
1013     if sys.version_info >= (3, 9):
1014         def __class_getitem__(cls, item: Any) -> GenericAlias: ...
1015
1016 # The result really is always a str.
1017 def getstatusoutput(cmd: _TXT) -> tuple[int, str]: ...
1018 def getoutput(cmd: _TXT) -> str: ...
1019
1020 if sys.version_info >= (3, 8):
1021     def list2cmdline(seq: Iterable[StrOrBytesPath]) -> str: ...  # undocumented
1022
1023 else:
1024     def list2cmdline(seq: Iterable[str]) -> str: ...  # undocumented
1025
1026 if sys.platform == "win32":
1027     class STARTUPINFO:
1028         if sys.version_info >= (3, 7):
1029             def __init__(
1030                 self,
1031                 *,
1032                 dwFlags: int = ...,
1033                 hStdInput: Any | None = ...,
1034                 hStdOutput: Any | None = ...,
1035                 hStdError: Any | None = ...,
1036                 wShowWindow: int = ...,
1037                 lpAttributeList: Mapping[str, Any] | None = ...,
1038             ) -> None: ...
1039         dwFlags: int
1040         hStdInput: Any | None
1041         hStdOutput: Any | None
1042         hStdError: Any | None
1043         wShowWindow: int
1044         if sys.version_info >= (3, 7):
1045             lpAttributeList: Mapping[str, Any]
1046     STD_INPUT_HANDLE: Any
1047     STD_OUTPUT_HANDLE: Any
1048     STD_ERROR_HANDLE: Any
1049     SW_HIDE: int
1050     STARTF_USESTDHANDLES: int
1051     STARTF_USESHOWWINDOW: int
1052     CREATE_NEW_CONSOLE: int
1053     CREATE_NEW_PROCESS_GROUP: int
1054     if sys.version_info >= (3, 7):
1055         ABOVE_NORMAL_PRIORITY_CLASS: int
1056         BELOW_NORMAL_PRIORITY_CLASS: int
1057         HIGH_PRIORITY_CLASS: int
1058         IDLE_PRIORITY_CLASS: int
1059         NORMAL_PRIORITY_CLASS: int
1060         REALTIME_PRIORITY_CLASS: int
1061         CREATE_NO_WINDOW: int
1062         DETACHED_PROCESS: int
1063         CREATE_DEFAULT_ERROR_MODE: int
1064         CREATE_BREAKAWAY_FROM_JOB: int