Debian Codegraph @

test-data/unit/lib-stub/contextlib.pyi

raw
1 from typing import AsyncIterator, Generic, TypeVar, Callable, Iterator
2 from typing import ContextManager as ContextManager, AsyncContextManager as AsyncContextManager
3
4 _T = TypeVar('_T')
5
6 class GeneratorContextManager(ContextManager[_T], Generic[_T]):
7 def __call__(self, func: Callable[..., _T]) -> Callable[..., _T]: ...
8
9 # This does not match `typeshed` definition, needs `ParamSpec`:
10 def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., GeneratorContextManager[_T]]:
11 ...
12
13 def asynccontextmanager(func: Callable[..., AsyncIterator[_T]]) -> Callable[..., AsyncContextManager[_T]]: ...