Skip to content
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

Fix signatures of call, check_call and check_output in subprocess #297

Merged
merged 1 commit into from
Jul 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 45 additions & 14 deletions stdlib/2.7/subprocess.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,51 @@ from typing import Sequence, Any, Mapping, Callable, Tuple, IO, Union, Optional

_FILE = Union[int, IO[Any]]

# TODO force keyword arguments
# TODO more keyword arguments (from Popen)
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: 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: Union[str, Sequence[str]], *,
stdin: _FILE = ..., stderr: _FILE = ...,
shell: bool = ..., universal_newlines: bool = ...,
env: Mapping[str, str] = ..., cwd: str = ...) -> str: ...
# Same args as Popen.__init__
def call(args: Union[str, Sequence[str]],
bufsize: int = ...,
executable: str = ...,
stdin: _FILE = ...,
stdout: _FILE = ...,
stderr: _FILE = ...,
preexec_fn: Callable[[], Any] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: str = ...,
env: Mapping[str, str] = ...,
universal_newlines: bool = ...,
startupinfo: Any = ...,
creationflags: int = ...) -> int: ...

def check_call(args: Union[str, Sequence[str]],
bufsize: int = ...,
executable: str = ...,
stdin: _FILE = ...,
stdout: _FILE = ...,
stderr: _FILE = ...,
preexec_fn: Callable[[], Any] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: str = ...,
env: Mapping[str, str] = ...,
universal_newlines: bool = ...,
startupinfo: Any = ...,
creationflags: int = ...) -> int: ...

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

PIPE = ... # type: int
STDOUT = ... # type: int
Expand Down
64 changes: 52 additions & 12 deletions stdlib/3/subprocess.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,61 @@

from typing import Sequence, Any, Mapping, Callable, Tuple, IO, Optional, Union

# TODO force keyword arguments
# TODO more keyword arguments
def call(args: Union[str, Sequence[str]], *, stdin: Any = ..., stdout: Any = ...,
stderr: Any = ..., shell: bool = ...,
# Same args as Popen.__init__
def call(args: Union[str, Sequence[str]],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new definition drops the fact that all arguments except for args are keyword-only.
(That's the right thing to do for 2.7/, but I'm guessing that for 3/ the '*' was actually justified)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, didn't know about the new keyword-only-args feature -- but looks like the Popen in python3 isn't using it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ptal ?

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] = ...,
cwd: str = ...) -> int: ...
def check_call(args: Union[str, Sequence[str]], *, stdin: Any = ..., stdout: Any = ...,
stderr: Any = ..., shell: bool = ...,
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] = ...,
cwd: str = ...) -> int: ...
# Return str/bytes
def check_output(args: Union[str, Sequence[str]], *, stdin: Any = ..., stderr: Any = ...,
shell: bool = ..., universal_newlines: bool = ...,
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] = ...,
cwd: str = ...) -> Any: ...
universal_newlines: bool = ...,
startupinfo: Any = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...) -> bytes: ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be bytes because check_output returns str when universal_newlines=True.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, my bad, sorry -- will check for similar errors and send fix, unless you already have one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's it - #348.


# TODO types
PIPE = ... # type: Any
Expand Down