-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
Describe the Bug
Await can be outside of a function if is in code that won't be executed automatically (ex: async generators).
awaitstatement outside of a function
This code is correct, yet ruff complains:
import asyncio
async def test2():
return "test"
async def a_gen():
for i in range(3):
yield test2()
a = (await cor async for cor in a_gen()) # `await` statement outside of a function F704
async def main():
async for i in a:
print(i)
if __name__ == "__main__":
asyncio.run(main())I suggest changing F704 so awaits are ok inside async generators that are basically syntax sugar of a function.
of course for now we can do the equivalent:
async def a():
for cor in a_gen():
yield await corVersion
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working