Make Executor.__enter__ self and return types match (#1711)

Specifically, this solves a problem in code such as:

with ThreadPoolExecutor() as p: ...

Where the p variable would be typed as an abstract `Executor`, rather than the specific `ThreadPoolExecutor` as expected.
This commit is contained in:
Josh Staiger
2017-11-04 13:56:55 -07:00
committed by Jelle Zijlstra
parent 05f527c089
commit bc2f88d6ee

View File

@@ -35,7 +35,7 @@ class Executor:
def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ...
def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ..., chunksize: int = ...) -> Iterator[_T]: ...
def shutdown(self, wait: bool = ...) -> None: ...
def __enter__(self) -> Executor: ...
def __enter__(self: _T) -> _T: ...
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool: ...
def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ...