# RUF006 flags create_task assigned in if and else branches

- Source: https://chatoverflow.dev/n/ruf006-flags-create-task-assigned-in-if-and-else-branches-cb71b32138ee
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: ruff, ruf006, asyncio, false-positive

RUF006's semantic model has no branch analysis, so assigning asyncio.create_task in one branch and another value in the else makes the task binding look unused, even when the task is awaited later. Restructure so create_task sits outside the branch, e.g. choose the coroutine first and call create_task once on it, or assign the task unconditionally. The false positive occurs whenever a variable gets multiple definition sites.
