|
3 | 3 | # Based on http://docs.python.org/3.2/library/subprocess.html
|
4 | 4 |
|
5 | 5 | import sys
|
6 |
| -from typing import Sequence, Any, Mapping, Callable, Tuple, IO, Optional, Union |
| 6 | +from typing import Sequence, Any, Mapping, Callable, Tuple, IO, Optional, Union, List |
| 7 | + |
| 8 | + |
| 9 | +if sys.version_info >= (3, 5): |
| 10 | + class CompletedProcess: |
| 11 | + args = ... # type: Union[List, str] |
| 12 | + returncode = ... # type: int |
| 13 | + stdout = ... # type: Union[str, bytes] |
| 14 | + stderr = ... # type: Union[str, bytes] |
| 15 | + def __init__(self, args: Union[List, str], |
| 16 | + returncode: int, |
| 17 | + stdout: Union[str, bytes], |
| 18 | + stderr: Union[str, bytes]) -> None: ... |
| 19 | + def check_returncode(self): ... |
| 20 | + |
| 21 | + # Nearly same args as Popen.__init__ except for timeout, input, and check |
| 22 | + def run(args: Union[str, Sequence[str]], |
| 23 | + timeout: int = ..., |
| 24 | + input: Union[str, bytes] = ..., |
| 25 | + check: bool = ..., |
| 26 | + bufsize: int = ..., |
| 27 | + executable: str = ..., |
| 28 | + stdin: Any = ..., |
| 29 | + stdout: Any = ..., |
| 30 | + stderr: Any = ..., |
| 31 | + preexec_fn: Callable[[], Any] = ..., |
| 32 | + close_fds: bool = ..., |
| 33 | + shell: bool = ..., |
| 34 | + cwd: str = ..., |
| 35 | + env: Mapping[str, str] = ..., |
| 36 | + universal_newlines: bool = ..., |
| 37 | + startupinfo: Any = ..., |
| 38 | + creationflags: int = ..., |
| 39 | + restore_signals: bool = ..., |
| 40 | + start_new_session: bool = ..., |
| 41 | + pass_fds: Any = ...) -> CompletedProcess: ... |
7 | 42 |
|
8 | 43 | # Same args as Popen.__init__
|
9 | 44 | def call(args: Union[str, Sequence[str]],
|
@@ -64,6 +99,9 @@ def check_output(args: Union[str, Sequence[str]],
|
64 | 99 | # TODO types
|
65 | 100 | PIPE = ... # type: Any
|
66 | 101 | STDOUT = ... # type: Any
|
| 102 | +if sys.version_info >= (3, 3): |
| 103 | + DEVNULL = ... # type: Any |
| 104 | + |
67 | 105 |
|
68 | 106 | class CalledProcessError(Exception):
|
69 | 107 | returncode = 0
|
|
0 commit comments