Improve contextlib (#406)

* remove old, new stubgen

* comment everything

* contextlib done

* use TypeVar instead of overload

* py2 done
This commit is contained in:
Valérian Rousset
2016-07-30 00:26:14 +02:00
committed by Matthias Kramm
parent 24086b2195
commit 1bd78d4aab
3 changed files with 53 additions and 34 deletions

View File

@@ -1,17 +0,0 @@
# Stubs for contextlib
# NOTE: These are incomplete!
from typing import Callable, Generic, Iterator, TypeVar
_T = TypeVar('_T')
class ContextManager(Generic[_T]):
def __enter__(self) -> _T: ...
def __exit__(self, *exc_info) -> None: ...
# TODO this doesn't capture the relationship that the returned function's args are the same as func's.
def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ...
class closing(ContextManager[_T], Generic[_T]):
def __init__(self, thing: _T) -> None: ...