From bc2f88d6eeb244a16d4955c12a8e0d00a6da1d5e Mon Sep 17 00:00:00 2001 From: Josh Staiger Date: Sat, 4 Nov 2017 13:56:55 -0700 Subject: [PATCH] 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. --- stdlib/3/concurrent/futures/_base.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3/concurrent/futures/_base.pyi b/stdlib/3/concurrent/futures/_base.pyi index 836756d5d..56b119b37 100644 --- a/stdlib/3/concurrent/futures/_base.pyi +++ b/stdlib/3/concurrent/futures/_base.pyi @@ -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]]: ...