Improve typing of 2.7/contextlib::contextmanager.

This commit is contained in:
Guido van Rossum
2015-11-25 16:59:50 -08:00
parent 00f8e62751
commit 76c3a5bab0

View File

@@ -2,13 +2,16 @@
# NOTE: These are incomplete!
from typing import Any, TypeVar, Generic
# TODO more precise type?
def contextmanager(func: Any) -> Any: ...
from typing import Any, TypeVar, Callable, Generic, Iterator
_T = TypeVar('_T')
class _GeneratorContextManager(Generic[_T]):
def __enter__(self) -> _T: ...
def __exit__(self, *exc_info) -> None: ...
def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., _GeneratorContextManager[_T]]: ...
class closing(Generic[_T]):
def __init__(self, thing: _T) -> None: ...
def __enter__(self) -> _T: ...