Skip to content

update subprocess module stub for Python 3.5 #426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 6, 2016
203 changes: 146 additions & 57 deletions stdlib/3/subprocess.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Stubs for subprocess

# Based on http://docs.python.org/3.2/library/subprocess.html
# Based on http://docs.python.org/3.5/library/subprocess.html
import sys

import sys
from typing import Sequence, Any, Mapping, Callable, Tuple, IO, Optional, Union, List
Expand All @@ -20,7 +21,7 @@ if sys.version_info >= (3, 5):

# Nearly same args as Popen.__init__ except for timeout, input, and check
def run(args: Union[str, Sequence[str]],
timeout: int = ...,
timeout: float = ...,
input: Union[str, bytes] = ...,
check: bool = ...,
bufsize: int = ...,
Expand All @@ -41,73 +42,161 @@ if sys.version_info >= (3, 5):
pass_fds: Any = ...) -> CompletedProcess: ...

# Same args as Popen.__init__
def call(args: Union[str, Sequence[str]],
bufsize: int = ...,
executable: str = ...,
stdin: Any = ...,
stdout: Any = ...,
stderr: Any = ...,
preexec_fn: Callable[[], Any] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: str = ...,
env: Mapping[str, str] = ...,
universal_newlines: bool = ...,
startupinfo: Any = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...) -> int: ...
if sys.version_info >= (3, 3):
# 3.3 added timeout
def call(args: Union[str, Sequence[str]],
bufsize: int = ...,
executable: str = ...,
stdin: Any = ...,
stdout: Any = ...,
stderr: Any = ...,
preexec_fn: Callable[[], Any] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: str = ...,
env: Mapping[str, str] = ...,
universal_newlines: bool = ...,
startupinfo: Any = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
timeout: float = ...) -> int: ...
else:
def call(args: Union[str, Sequence[str]],
bufsize: int = ...,
executable: str = ...,
stdin: Any = ...,
stdout: Any = ...,
stderr: Any = ...,
preexec_fn: Callable[[], Any] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: str = ...,
env: Mapping[str, str] = ...,
universal_newlines: bool = ...,
startupinfo: Any = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...) -> int: ...

# Same args as Popen.__init__
def check_call(args: Union[str, Sequence[str]],
bufsize: int = ...,
executable: str = ...,
stdin: Any = ...,
stdout: Any = ...,
stderr: Any = ...,
preexec_fn: Callable[[], Any] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: str = ...,
env: Mapping[str, str] = ...,
universal_newlines: bool = ...,
startupinfo: Any = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...) -> int: ...

# Same args as Popen.__init__, except for stdout
def check_output(args: Union[str, Sequence[str]],
bufsize: int = ...,
executable: str = ...,
stdin: Any = ...,
stderr: Any = ...,
preexec_fn: Callable[[], Any] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: str = ...,
env: Mapping[str, str] = ...,
universal_newlines: bool = ...,
startupinfo: Any = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...) -> Any: ...
if sys.version_info >= (3, 3):
# 3.3 added timeout
def check_call(args: Union[str, Sequence[str]],
bufsize: int = ...,
executable: str = ...,
stdin: Any = ...,
stdout: Any = ...,
stderr: Any = ...,
preexec_fn: Callable[[], Any] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: str = ...,
env: Mapping[str, str] = ...,
universal_newlines: bool = ...,
startupinfo: Any = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
timeout: float = ...) -> int: ...
else:
def check_call(args: Union[str, Sequence[str]],
bufsize: int = ...,
executable: str = ...,
stdin: Any = ...,
stdout: Any = ...,
stderr: Any = ...,
preexec_fn: Callable[[], Any] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: str = ...,
env: Mapping[str, str] = ...,
universal_newlines: bool = ...,
startupinfo: Any = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...) -> int: ...

if sys.version_info >= (3, 4):
# 3.4 added input
def check_output(args: Union[str, Sequence[str]],
bufsize: int = ...,
executable: str = ...,
stdin: Any = ...,
stderr: Any = ...,
preexec_fn: Callable[[], Any] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: str = ...,
env: Mapping[str, str] = ...,
universal_newlines: bool = ...,
startupinfo: Any = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
timeout: float = ...,
input: Union[str, bytes] = ...) -> Any: ...
elif sys.version_info >= (3, 3):
# 3.3 added timeout
def check_output(args: Union[str, Sequence[str]],
bufsize: int = ...,
executable: str = ...,
stdin: Any = ...,
stderr: Any = ...,
preexec_fn: Callable[[], Any] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: str = ...,
env: Mapping[str, str] = ...,
universal_newlines: bool = ...,
startupinfo: Any = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
timeout: float = ...) -> Any: ...
else:
# Same args as Popen.__init__, except for stdout
def check_output(args: Union[str, Sequence[str]],
bufsize: int = ...,
executable: str = ...,
stdin: Any = ...,
stderr: Any = ...,
preexec_fn: Callable[[], Any] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: str = ...,
env: Mapping[str, str] = ...,
universal_newlines: bool = ...,
startupinfo: Any = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...) -> Any: ...


# TODO types
PIPE = ... # type: Any
STDOUT = ... # type: Any
if sys.version_info >= (3, 3):
DEVNULL = ... # type: Any
DEVNULL = ... # type: Any
class SubprocessError(Exception): ...


class CalledProcessError(Exception):
returncode = 0
cmd = ... # type: str
output = b'' # May be None

if sys.version_info >= (3, 5):
stdout = b''
stderr = b''

def __init__(self, returncode: int, cmd: str, output: Optional[str] = ...,
stderr: Optional[str] = ...) -> None: ...

Expand Down Expand Up @@ -141,9 +230,9 @@ class Popen:
def wait(self) -> int: ...
# Return str/bytes
if sys.version_info >= (3, 3):
def communicate(self, input=..., timeout: float = ...) -> Tuple[Any, Any]: ...
def communicate(self, input: Union[str, bytes] = ..., timeout: float =...) -> Tuple[Any, Any]: ...
else:
def communicate(self, input=...) -> Tuple[Any, Any]: ...
def communicate(self, input: Union[str, bytes] = ...) -> Tuple[Any, Any]: ...
def send_signal(self, signal: int) -> None: ...
def terminate(self) -> None: ...
def kill(self) -> None: ...
Expand Down