mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
Fix subprocess stubs (#198)
* subprocess.CalledProcessError output argument is optional. * subprocess.CalledProcessError takes stderr argument in python3. * subprocess: Fix type for command in call() and friends. The stubs didn't correctly support the fact that you can pass a string as well as a sequence of strings.
This commit is contained in:
committed by
Guido van Rossum
parent
9fdac6e0df
commit
ea734c69d0
@@ -8,15 +8,15 @@ _FILE = Union[int, IO[Any]]
|
||||
|
||||
# TODO force keyword arguments
|
||||
# TODO more keyword arguments (from Popen)
|
||||
def call(args: Sequence[str], *,
|
||||
def call(args: Union[str, Sequence[str]], *,
|
||||
stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ...,
|
||||
shell: bool = ..., env: Mapping[str, str] = ...,
|
||||
cwd: str = ...) -> int: ...
|
||||
def check_call(args: Sequence[str], *,
|
||||
def check_call(args: Union[str, Sequence[str]], *,
|
||||
stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ...,
|
||||
shell: bool = ..., env: Mapping[str, str] = ..., cwd: str = ...,
|
||||
close_fds: Sequence[_FILE] = ..., preexec_fn: Callable[[], Any] = ...) -> int: ...
|
||||
def check_output(args: Sequence[str], *,
|
||||
def check_output(args: Union[str, Sequence[str]], *,
|
||||
stdin: _FILE = ..., stderr: _FILE = ...,
|
||||
shell: bool = ..., universal_newlines: bool = ...,
|
||||
env: Mapping[str, str] = ..., cwd: str = ...) -> str: ...
|
||||
@@ -29,7 +29,7 @@ class CalledProcessError(Exception):
|
||||
cmd = ... # type: str
|
||||
output = ... # type: str # May be None
|
||||
|
||||
def __init__(self, returncode: int, cmd: str, output: str = ...) -> None: ...
|
||||
def __init__(self, returncode: int, cmd: str, output: Optional[str] = ...) -> None: ...
|
||||
|
||||
class Popen:
|
||||
stdin = ... # type: Optional[IO[Any]]
|
||||
@@ -39,7 +39,7 @@ class Popen:
|
||||
returncode = 0
|
||||
|
||||
def __init__(self,
|
||||
args: Sequence[str],
|
||||
args: Union[str, Sequence[str]],
|
||||
bufsize: int = ...,
|
||||
executable: str = ...,
|
||||
stdin: _FILE = ...,
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
|
||||
# Based on http://docs.python.org/3.2/library/subprocess.html
|
||||
|
||||
from typing import Sequence, Any, Mapping, Callable, Tuple, IO
|
||||
from typing import Sequence, Any, Mapping, Callable, Tuple, IO, Optional, Union
|
||||
|
||||
# TODO force keyword arguments
|
||||
# TODO more keyword arguments
|
||||
def call(args: Sequence[str], *, stdin: Any = ..., stdout: Any = ...,
|
||||
def call(args: Union[str, Sequence[str]], *, stdin: Any = ..., stdout: Any = ...,
|
||||
stderr: Any = ..., shell: bool = ...,
|
||||
env: Mapping[str, str] = ...,
|
||||
cwd: str = ...) -> int: ...
|
||||
def check_call(args: Sequence[str], *, stdin: Any = ..., stdout: Any = ...,
|
||||
def check_call(args: Union[str, Sequence[str]], *, stdin: Any = ..., stdout: Any = ...,
|
||||
stderr: Any = ..., shell: bool = ...,
|
||||
env: Mapping[str, str] = ...,
|
||||
cwd: str = ...) -> int: ...
|
||||
# Return str/bytes
|
||||
def check_output(args: Sequence[str], *, stdin: Any = ..., stderr: Any = ...,
|
||||
def check_output(args: Union[str, Sequence[str]], *, stdin: Any = ..., stderr: Any = ...,
|
||||
shell: bool = ..., universal_newlines: bool = ...,
|
||||
env: Mapping[str, str] = ...,
|
||||
cwd: str = ...) -> Any: ...
|
||||
@@ -29,7 +29,8 @@ class CalledProcessError(Exception):
|
||||
cmd = ... # type: str
|
||||
output = b'' # May be None
|
||||
|
||||
def __init__(self, returncode: int, cmd: str, output: str = ...) -> None: ...
|
||||
def __init__(self, returncode: int, cmd: str, output: Optional[str],
|
||||
stderr: Optional[str] = ...) -> None: ...
|
||||
|
||||
class Popen:
|
||||
stdin = ... # type: IO[Any]
|
||||
@@ -39,7 +40,7 @@ class Popen:
|
||||
returncode = 0
|
||||
|
||||
def __init__(self,
|
||||
args: Sequence[str],
|
||||
args: Union[str, Sequence[str]],
|
||||
bufsize: int = ...,
|
||||
executable: str = ...,
|
||||
stdin: Any = ...,
|
||||
|
||||
Reference in New Issue
Block a user