Add new arguments to subprocess.Popen (#7798)

This commit is contained in:
Jelle Zijlstra
2022-05-06 23:49:23 -07:00
committed by GitHub
parent 16ca92fac7
commit 6b5068b11d

View File

@@ -804,7 +804,556 @@ class Popen(Generic[AnyStr]):
# Technically it is wrong that Popen provides __new__ instead of __init__
# but this shouldn't come up hopefully?
if sys.version_info >= (3, 7):
if sys.version_info >= (3, 11):
# process_group is added in 3.11
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: bool = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: bool | None = ...,
encoding: str,
errors: str | None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
pipesize: int = ...,
process_group: int | None = ...,
) -> Popen[str]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: bool = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: bool | None = ...,
encoding: str | None = ...,
errors: str,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
pipesize: int = ...,
process_group: int | None = ...,
) -> Popen[str]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
*,
universal_newlines: Literal[True],
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
# where the *real* keyword only args start
text: bool | None = ...,
encoding: str | None = ...,
errors: str | None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
pipesize: int = ...,
process_group: int | None = ...,
) -> Popen[str]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: bool = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: Literal[True],
encoding: str | None = ...,
errors: str | None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
pipesize: int = ...,
process_group: int | None = ...,
) -> Popen[str]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: Literal[False] = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: Literal[None, False] = ...,
encoding: None = ...,
errors: None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
pipesize: int = ...,
process_group: int | None = ...,
) -> Popen[bytes]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: bool = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: bool | None = ...,
encoding: str | None = ...,
errors: str | None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
pipesize: int = ...,
process_group: int | None = ...,
) -> Popen[Any]: ...
elif sys.version_info >= (3, 10):
# pipesize is added in 3.10
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: bool = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: bool | None = ...,
encoding: str,
errors: str | None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
pipesize: int = ...,
) -> Popen[str]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: bool = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: bool | None = ...,
encoding: str | None = ...,
errors: str,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
pipesize: int = ...,
) -> Popen[str]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
*,
universal_newlines: Literal[True],
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
# where the *real* keyword only args start
text: bool | None = ...,
encoding: str | None = ...,
errors: str | None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
pipesize: int = ...,
) -> Popen[str]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: bool = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: Literal[True],
encoding: str | None = ...,
errors: str | None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
pipesize: int = ...,
) -> Popen[str]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: Literal[False] = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: Literal[None, False] = ...,
encoding: None = ...,
errors: None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
pipesize: int = ...,
) -> Popen[bytes]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: bool = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: bool | None = ...,
encoding: str | None = ...,
errors: str | None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
pipesize: int = ...,
) -> Popen[Any]: ...
elif sys.version_info >= (3, 9):
# user, group, extra_groups, umask were added in 3.9
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: bool = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: bool | None = ...,
encoding: str,
errors: str | None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
) -> Popen[str]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: bool = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: bool | None = ...,
encoding: str | None = ...,
errors: str,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
) -> Popen[str]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
*,
universal_newlines: Literal[True],
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
# where the *real* keyword only args start
text: bool | None = ...,
encoding: str | None = ...,
errors: str | None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
) -> Popen[str]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: bool = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: Literal[True],
encoding: str | None = ...,
errors: str | None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
) -> Popen[str]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: Literal[False] = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: Literal[None, False] = ...,
encoding: None = ...,
errors: None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
) -> Popen[bytes]: ...
@overload
def __new__(
cls,
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath | None = ...,
stdin: _FILE | None = ...,
stdout: _FILE | None = ...,
stderr: _FILE | None = ...,
preexec_fn: Callable[[], Any] | None = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: StrOrBytesPath | None = ...,
env: _ENV | None = ...,
universal_newlines: bool = ...,
startupinfo: Any | None = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
text: bool | None = ...,
encoding: str | None = ...,
errors: str | None = ...,
user: str | int | None = ...,
group: str | int | None = ...,
extra_groups: Iterable[str | int] | None = ...,
umask: int = ...,
) -> Popen[Any]: ...
elif sys.version_info >= (3, 7):
# text is added in 3.7
@overload
def __new__(