From dccc29bc2f6b4d95ed6b085df889229c1d121069 Mon Sep 17 00:00:00 2001 From: George King Date: Wed, 7 Dec 2016 17:46:34 -0500 Subject: [PATCH] Add `None` to type union for `subprocess.Popen.communicate` `input`. (#743) * Add `None` to type union for `subprocess.Popen.communicate` stub's `input` parameter. * subprocess.communicate `input` annotated as `Optional[AnyStr]` for both 2.7 and 3.x; `timeout` as `Optional[float]`. --- stdlib/2/subprocess.pyi | 4 ++-- stdlib/3/subprocess.pyi | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stdlib/2/subprocess.pyi b/stdlib/2/subprocess.pyi index 8286e83d0..e8ec596b7 100644 --- a/stdlib/2/subprocess.pyi +++ b/stdlib/2/subprocess.pyi @@ -2,7 +2,7 @@ # Based on http://docs.python.org/2/library/subprocess.html and Python 3 stub -from typing import Sequence, Any, Mapping, Callable, Tuple, IO, Union, Optional +from typing import Sequence, Any, AnyStr, Mapping, Callable, Tuple, IO, Union, Optional _FILE = Union[int, IO[Any]] @@ -87,7 +87,7 @@ class Popen: def poll(self) -> int: ... def wait(self) -> int: ... - def communicate(self, input: Union[bytes, unicode] = ...) -> Tuple[Optional[bytes], Optional[bytes]]: ... + def communicate(self, input: Optional[AnyStr] = ...) -> Tuple[Optional[bytes], Optional[bytes]]: ... def send_signal(self, signal: int) -> None: ... def terminate(self) -> None: ... def kill(self) -> None: ... diff --git a/stdlib/3/subprocess.pyi b/stdlib/3/subprocess.pyi index 11b108fd4..ea1071044 100644 --- a/stdlib/3/subprocess.pyi +++ b/stdlib/3/subprocess.pyi @@ -2,7 +2,7 @@ # Based on http://docs.python.org/3.5/library/subprocess.html import sys -from typing import Sequence, Any, Mapping, Callable, Tuple, IO, Optional, Union, List, Type +from typing import Sequence, Any, AnyStr, Mapping, Callable, Tuple, IO, Optional, Union, List, Type from types import TracebackType @@ -234,9 +234,9 @@ class Popen: def wait(self) ->int: ... # Return str/bytes if sys.version_info >= (3, 3): - def communicate(self, input: Union[str, bytes] = ..., timeout: float = ...) -> Tuple[Any, Any]: ... + def communicate(self, input: Optional[AnyStr] = ..., timeout: Optional[float] = ...) -> Tuple[Any, Any]: ... else: - def communicate(self, input: Union[str, bytes] = ...) -> Tuple[Any, Any]: ... + def communicate(self, input: Optional[AnyStr] = ...) -> Tuple[Any, Any]: ... def send_signal(self, signal: int) -> None: ... def terminate(self) -> None: ... def kill(self) -> None: ...