mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
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. :-)
This commit is contained in:
@@ -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: ...
|
||||
|
||||
Reference in New Issue
Block a user