You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reveal_type(yield_id) # N: Revealed type is "def [T] (item: T`-1) -> contextlib.GeneratorContextManager[T`-1]"
39
-
40
-
with yield_id(1) as x:
41
-
reveal_type(x) # N: Revealed type is "builtins.int*"
42
-
43
-
f = yield_id
44
-
def g(x, y): pass
45
-
f = g # E: Incompatible types in assignment (expression has type "Callable[[Any, Any], Any]", variable has type "Callable[[T], GeneratorContextManager[T]]")
46
-
[typing fixtures/typing-medium.pyi]
47
-
[builtins fixtures/tuple.pyi]
48
-
49
27
[case testAsyncContextManagerWithGenericFunction]
50
28
# flags: --python-version 3.7
51
29
from contextlib import asynccontextmanager
52
-
from typing import TypeVar, AsyncIterator
53
-
54
-
T = TypeVar('T')
55
-
56
-
@asynccontextmanager
57
-
async def yield_id(item: T) -> AsyncIterator[T]:
58
-
yield item
59
-
60
-
reveal_type(yield_id) # N: Revealed type is "def [T] (item: T`-1) -> typing.AsyncContextManager[T`-1]"
61
-
62
-
async with yield_id(1) as x:
63
-
reveal_type(x) # N: Revealed type is "builtins.int*"
0 commit comments