-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add async119: yield in contextmanager in async generator
- Loading branch information
Showing
5 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import contextlib | ||
|
||
from contextlib import asynccontextmanager | ||
|
||
|
||
async def unsafe_yield(): | ||
with open(""): | ||
yield # error: 8 | ||
|
||
|
||
async def async_with(): | ||
async with unsafe_yield(): | ||
yield # error: 8 | ||
|
||
|
||
async def yield_not_in_contextmanager(): | ||
yield | ||
with open(""): | ||
... | ||
yield | ||
|
||
|
||
async def yield_in_nested_function(): | ||
with open(""): | ||
|
||
def foo(): | ||
yield | ||
|
||
|
||
async def yield_in_nested_async_function(): | ||
with open(""): | ||
|
||
async def foo(): | ||
yield | ||
|
||
|
||
async def yield_after_nested_async_function(): | ||
with open(""): | ||
|
||
async def foo(): | ||
yield | ||
|
||
yield # error: 8 | ||
|
||
|
||
@asynccontextmanager | ||
async def safe_in_contextmanager(): | ||
with open(""): | ||
yield | ||
|
||
|
||
@contextlib.asynccontextmanager | ||
async def safe_in_contextmanager2(): | ||
with open(""): | ||
yield |