diff --git a/stdlib/3/subprocess.pyi b/stdlib/3/subprocess.pyi index 802fd750e0ae..880b08ed6fad 100644 --- a/stdlib/3/subprocess.pyi +++ b/stdlib/3/subprocess.pyi @@ -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 @@ -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 = ..., @@ -41,66 +42,150 @@ 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): @@ -108,6 +193,10 @@ class CalledProcessError(Exception): 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: ... @@ -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: ...