Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contextmanager decorators require Generators #2773

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions stdlib/2and3/contextlib.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Stubs for contextlib

from typing import (
Any, Callable, Generator, IO, Iterable, Iterator, Optional, Type,
Any, Callable, Generator, IO, Iterable, Optional, Type,
Generic, TypeVar, overload
)
from types import TracebackType
Expand All @@ -10,7 +10,7 @@ import sys
from typing import ContextManager as ContextManager

if sys.version_info >= (3, 5):
from typing import AsyncContextManager, AsyncIterator
from typing import AsyncContextManager, AsyncGenerator

if sys.version_info >= (3, 6):
from typing import ContextManager as AbstractContextManager
Expand All @@ -27,12 +27,12 @@ _CM_EF = TypeVar('_CM_EF', ContextManager, _ExitFunc)
if sys.version_info >= (3, 2):
class GeneratorContextManager(ContextManager[_T], Generic[_T]):
def __call__(self, func: Callable[..., _T]) -> Callable[..., _T]: ...
def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., GeneratorContextManager[_T]]: ...
def contextmanager(func: Callable[..., Generator[_T, Any, Any]]) -> Callable[..., GeneratorContextManager[_T]]: ...
else:
def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ...
def contextmanager(func: Callable[..., Generator[_T, Any, Any]]) -> Callable[..., ContextManager[_T]]: ...

if sys.version_info >= (3, 7):
def asynccontextmanager(func: Callable[..., AsyncIterator[_T]]) -> Callable[..., AsyncContextManager[_T]]: ...
def asynccontextmanager(func: Callable[..., AsyncGenerator[_T, Any]]) -> Callable[..., AsyncContextManager[_T]]: ...

if sys.version_info < (3,):
def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ...
Expand Down