-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Detect asyncio-dangling-task
(RUF006
) when discarding return value
#8863
Comments
asyncio-dangling-task
when discarding return valueasyncio-dangling-task
(RUF006
) when discarding return value
asyncio-dangling-task
(RUF006
) when discarding return valueasyncio-dangling-task
(RUF006
) when discarding return value
This seems reasonable to me! |
Hye, @tjkuson MinimizingI'm new to Ruff's contributions. I try to duplicate your issue by compiling Ruff using
game.py: import asyncio
async def some_coro(param):
print(f"Executing coroutine with param: {param}")
await asyncio.sleep(1)
print(f"Coroutine with param {param} completed")
async def main():
for i in range(10):
asyncio.create_task(some_coro(param=i))
if __name__ == "__main__":
asyncio.run(main()) I expected it would produce an error: The result is also the same for this snippet. _ = asyncio.create_task(some_coro(param=i)) Python Version:
Local Machine:
Edit: The rule is disabled by default. Use:
|
I'm not sure if this behavior is intentional, similar to that ruff allows |
@MichaReiser - Not intentional -- this rule doesn't look at assignments, it only looks at standalone expressions that include |
@allaboutevemirolive I think you need to select the rule (it isn't enabled by default) using |
Hi,I gave it a try. |
Thanks @asafamr-mm! |
triggers
asyncio-dangling-task
butdoes not.
I would expect Ruff to trigger
asyncio-dangling-task
when the return value ofasyncio.create_task
is discarded, following the rationale of the rule.The text was updated successfully, but these errors were encountered: