From 53f0ed7e689d7e59da12c2241bdecde8514333ab Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 2 Aug 2016 12:03:58 -0700 Subject: [PATCH] Fix signature of nested() -- it actually returns a list of values. To be on the conservative side I'm making it an Iterable of values; this should be good enough for common usages. The types of the values actually correspond to the types of the argument ContextManagers, but a proper signature would require variadic type variables (https://github.com/python/typing/issues/193), which isn't worth waiting for. :-) --- stdlib/2and3/contextlib.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/2and3/contextlib.pyi b/stdlib/2and3/contextlib.pyi index 495b24f0d..0f14afaee 100644 --- a/stdlib/2and3/contextlib.pyi +++ b/stdlib/2and3/contextlib.pyi @@ -1,7 +1,7 @@ # Stubs for contextlib from typing import ( - Any, Callable, Generator, IO, Iterator, Optional, Type, + Any, Callable, Generator, IO, Iterable, Iterator, Optional, Type, Generic, TypeVar, ) from types import TracebackType @@ -23,7 +23,7 @@ class ContextManager(Generic[_T]): def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... if sys.version_info < (3,): - def nested(*mgr: ContextManager[Any]) -> ContextManager[None]: ... + def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ... class closing(Generic[_T], ContextManager[_T]): def __init__(self, thing: _T) -> None: ...